Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Unified Diff: experimental/SkV8Example/Global.h

Issue 118473006: Allow multiple concurrent timers. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: clean up Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | experimental/SkV8Example/Global.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | experimental/SkV8Example/Global.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698