forked from dgl/javascript-v8
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathV8Thread.h
More file actions
36 lines (28 loc) · 847 Bytes
/
V8Thread.h
File metadata and controls
36 lines (28 loc) · 847 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
35
36
#include <pthread.h>
#include <iostream>
#include <memory>
#include <v8.h>
using namespace std;
using namespace v8;
typedef struct thread_status {
auto_ptr<string> error;
auto_ptr<string> result;
} thread_status;
class V8Thread {
private:
pthread_t thread;
Isolate *isolate;
Persistent<Context> context;
Persistent<Function> function;
public:
V8Thread(const char *code, const char *origin);
~V8Thread();
static void install(Handle<Object> global);
static Handle<Value> _create(const Arguments& args);
static Handle<Value> _start(const Arguments& args);
static Handle<Value> _join(const Arguments& args);
static void _destroy(Isolate* isolate, Persistent<Value> object, void* data);
void start(const char* code);
thread_status* run(const char* arg);
thread_status* join();
};