-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathv8isolate.h
38 lines (30 loc) · 1022 Bytes
/
v8isolate.h
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
35
36
37
38
#ifndef V8ISOLATE_H
#define V8ISOLATE_H
#include "v8.h"
#include "v8context.h"
#include "v8wrap.h"
class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
public:
virtual void* Allocate(size_t length);
virtual void* AllocateUninitialized(size_t length);
virtual void Free(void* data, size_t);
};
class V8Isolate {
public:
V8Isolate();
V8Isolate(v8::StartupData* startup_data);
~V8Isolate();
V8Context* MakeContext();
// May be called any any time, will forcefully terminate the VM.
void Terminate();
// Unlocks the isolate, allowing other threads to use it. During this
// time, the current thread may not access V8. This is intended to be
// used for long-running callbacks, allowing the isolate to be used
// elsewhere while the callback is running. Delete the returned
// unlocker object to re-lock the isolate and start accessing it again.
v8::Unlocker* Unlock();
private:
v8::Isolate* isolate_;
ArrayBufferAllocator allocator;
};
#endif // !defined(V8ISOLATE_H)