static void RunIsolate(void* arg) {
ThreadInfo* ti = reinterpret_cast<ThreadInfo*>(arg);
- uv_loop_t* loop = uv_loop_new();
- Isolate* isolate = Isolate::New(loop);
+ Isolate* isolate = Isolate::New();
StartThread(isolate, ti->argc_, ti->argv_);
delete ti;
// Create the main node::Isolate object
node::Isolate::Initialize();
- Isolate* isolate = node::Isolate::New(uv_default_loop());
+ Isolate* isolate = node::Isolate::New();
StartThread(isolate, argc, argv);
isolate->Dispose();
}
}
-Isolate* Isolate::New(uv_loop_t* loop) {
- return new Isolate(loop);
+
+Isolate* Isolate::New() {
+ return new Isolate();
}
-Isolate::Isolate(uv_loop_t* loop) {
+Isolate::Isolate() {
assert(initialized && "node::Isolate::Initialize() hasn't been called");
uv_mutex_lock(&id_lock);
id_ = ++id;
uv_mutex_unlock(&id_lock);
+ if (id_ == 1) {
+ loop_ = uv_default_loop();
+ } else {
+ loop_ = uv_loop_new();
+ }
+
ngx_queue_init(&at_exit_callbacks_);
- loop_ = loop;
v8_isolate_ = v8::Isolate::GetCurrent();
if (v8_isolate_ == NULL) {
typedef void (*AtExitCallback)(void* arg);
- static Isolate* New(uv_loop_t* loop);
+ static Isolate* New();
static Isolate* GetCurrent() {
return reinterpret_cast<Isolate*>(v8::Isolate::GetCurrent()->GetData());
unsigned int id_;
private:
- Isolate(uv_loop_t* loop);
+ Isolate();
struct AtExitCallbackInfo {
ngx_queue_t at_exit_callbacks_;