Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef HAVE_TIMERS_H
00020 #define HAVE_TIMERS_H
00021
00022 #include "dsodefs.h"
00023 #include "smart_ptr.h"
00024 #include "fn_call.h"
00025
00026 #include <string>
00027 #include <limits>
00028
00029
00030 namespace gnash {
00031 class as_function;
00032 class as_object;
00033 }
00034
00035 namespace gnash {
00036
00038
00052 class DSOEXPORT Timer
00053 {
00054 public:
00055
00056 ~Timer();
00057
00059
00078 Timer(as_function& method, unsigned long ms, as_object* this_ptr,
00079 const fn_call::Args& args, bool runOnce = false);
00080
00082
00100 Timer(as_object* obj, string_table::key methodName, unsigned long ms,
00101 const fn_call::Args& args, bool runOnce = false);
00102
00104
00110 void clearInterval();
00111
00113
00122 bool expired(unsigned long now, unsigned long& elapsed);
00123
00125
00128 bool cleared() const {
00129 return _start == std::numeric_limits<unsigned long>::max();
00130 }
00131
00133
00141 void executeAndReset();
00142
00143 #ifdef GNASH_USE_GC
00144
00145
00152 void markReachableResources() const;
00153 #endif // GNASH_USE_GC
00154
00155 private:
00156
00158 void execute();
00159
00161 void operator() () { execute(); }
00162
00164 unsigned long getInterval() const { return _interval; }
00165
00167 unsigned long getStart() const { return _start; }
00168
00170
00173 void start();
00174
00176 unsigned int _interval;
00177
00179
00183 unsigned long _start;
00184
00187 as_function* _function;
00188
00189 string_table::key _methodName;
00190
00192 as_object* _object;
00193
00195
00197 const fn_call::Args _args;
00198
00200 bool _runOnce;
00201 };
00202
00203 }
00204
00205 #endif