Index: experimental/SkV8Example/Global.h |
diff --git a/experimental/SkV8Example/Global.h b/experimental/SkV8Example/Global.h |
index aa05b01aaf8c806452003816696137be7bed6557..3377e21ede750383f8a7ef857fcc3b427130673a 100644 |
--- a/experimental/SkV8Example/Global.h |
+++ b/experimental/SkV8Example/Global.h |
@@ -10,6 +10,8 @@ |
#ifndef SkV8Example_Global_DEFINED |
#define SkV8Example_Global_DEFINED |
robertphillips
2013/12/20 14:49:43
I'm not sure if we want to start using STL. Though
jcgregorio
2013/12/20 14:53:07
Yeah, I was hesitant on that, are there Sk* altern
|
+#include <map> |
+ |
#include <v8.h> |
using namespace v8; |
@@ -19,6 +21,8 @@ using namespace v8; |
class SkOSWindow; |
+typedef Persistent<Function, CopyablePersistentTraits<Function> > CopyablePersistentFn; |
+ |
// Provides the global isolate and context for our V8 instance. |
// Also implements all the global level functions. |
class Global : SkNoncopyable { |
@@ -26,6 +30,7 @@ public: |
Global(Isolate* isolate) |
: fIsolate(isolate) |
, fWindow(NULL) |
+ , fLastTimerID(0) |
{ |
gGlobal = this; |
} |
@@ -53,6 +58,7 @@ public: |
private: |
Handle<Context> createRootContext(); |
+ int32_t getNextTimerID(); |
static bool TimeOutProc(const SkEvent& evt); |
@@ -67,8 +73,11 @@ private: |
SkOSWindow* fWindow; |
static Global* gGlobal; |
- // Handle to the function to call when the timeout triggers. |
- Persistent<Function> fTimeout; |
+ // Handle to the functions to call when a timeout triggers as indexed by id. |
+ std::map<int32_t, CopyablePersistentFn > fTimeouts; |
+ |
+ // Last timer ID generated. |
+ int32_t fLastTimerID; |
}; |
#endif |