Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2012-01-10 19:46:06 +0400
committerBen Noordhuis <info@bnoordhuis.nl>2012-01-10 19:46:41 +0400
commit7cee968c21278d7a947a58699f7ce5413ad48973 (patch)
treef222b7567c69c29dd5d6931b2b487e0efc965cc8 /src
parent6b2091b58ab7cdef5651aa16641c5f274687561f (diff)
isolates: add process-global list of isolates
Diffstat (limited to 'src')
-rw-r--r--src/node_isolate.cc6
-rw-r--r--src/node_isolate.h1
2 files changed, 7 insertions, 0 deletions
diff --git a/src/node_isolate.cc b/src/node_isolate.cc
index ede131faf01..8f57a0b3b7b 100644
--- a/src/node_isolate.cc
+++ b/src/node_isolate.cc
@@ -60,6 +60,7 @@ using v8::Undefined;
static volatile bool initialized;
static volatile int id;
static volatile int isolate_count;
+static ngx_queue_t isolate_list;
static uv_mutex_t isolate_mutex;
#ifdef NDEBUG
@@ -230,6 +231,7 @@ void Isolate::OnMessage(IsolateMessage* msg, void* arg) {
void Isolate::Initialize() {
if (initialized) return;
if (uv_mutex_init(&isolate_mutex)) abort();
+ ngx_queue_init(&isolate_list);
initialized = true;
}
@@ -249,6 +251,7 @@ Isolate::Isolate() {
uv_mutex_lock(&isolate_mutex);
assert(initialized && "node::Isolate::Initialize() hasn't been called");
+ ngx_queue_insert_tail(&isolate_list, &isolate_list_);
isolate_count++;
id_ = ++id;
uv_mutex_unlock(&isolate_mutex);
@@ -344,7 +347,10 @@ void Isolate::Dispose() {
uv_mutex_lock(&isolate_mutex);
isolate_count--;
+ ngx_queue_remove(&isolate_list_);
assert(isolate_count >= 0);
+ assert((isolate_count == 0 && ngx_queue_empty(&isolate_list))
+ || (isolate_count > 0 && !ngx_queue_empty(&isolate_list)));
uv_mutex_unlock(&isolate_mutex);
}
diff --git a/src/node_isolate.h b/src/node_isolate.h
index 667ee24ad1a..b08ecf39123 100644
--- a/src/node_isolate.h
+++ b/src/node_isolate.h
@@ -128,6 +128,7 @@ private:
void operator=(const Isolate&) {}
Isolate(const Isolate&) {}
+ ngx_queue_t isolate_list_; // linked list of all isolates
ngx_queue_t at_exit_callbacks_;
v8::Persistent<v8::Context> v8_context_;
v8::Isolate* v8_isolate_;