-
-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathSetTimeout.h
More file actions
34 lines (26 loc) · 897 Bytes
/
SetTimeout.h
File metadata and controls
34 lines (26 loc) · 897 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifndef SetTimeout_h
#define SetTimeout_h
#include "Common.h"
#include "robin_hood.h"
namespace tns {
class SetTimeout {
public:
static void Init(v8::Isolate* isolate, v8::Local<v8::ObjectTemplate> globalTemplate);
private:
static void SetTimeoutCallback(const v8::FunctionCallbackInfo<v8::Value>& args);
static void ClearTimeoutCallback(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Elapsed(const uint32_t key);
static void RemoveKey(const uint32_t key);
static uint32_t count_;
struct CacheEntry {
CacheEntry(v8::Isolate* isolate, v8::Persistent<v8::Function>* callback)
: isolate_(isolate),
callback_(callback) {
}
v8::Isolate* isolate_;
v8::Persistent<v8::Function>* callback_;
};
static robin_hood::unordered_map<uint32_t, CacheEntry> cache_;
};
}
#endif /* SetTimeout_h */