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
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2013-08-11 02:26:11 +0400
committerBen Noordhuis <info@bnoordhuis.nl>2013-09-06 07:51:42 +0400
commit756b6222956b5d25b2e7db81f4e79033a3a4d20e (patch)
treeeb03b6f0bf33c36e011858c4a31b10a6eaadfc19 /src/pipe_wrap.h
parent81655a224a36948291e1f21f03273b5b604b7e6a (diff)
src: add multi-context support
This commit makes it possible to use multiple V8 execution contexts within a single event loop. Put another way, handle and request wrap objects now "remember" the context they belong to and switch back to that context when the time comes to call into JS land. This could have been done in a quick and hacky way by calling v8::Object::GetCreationContext() on the wrap object right before making a callback but that leaves a fairly wide margin for bugs. Instead, we make the context explicit through a new Environment class that encapsulates everything (or almost everything) that belongs to the context. Variables that used to be a static or a global are now members of the aforementioned class. An additional benefit is that this approach should make it relatively straightforward to add full isolate support in due course. There is no JavaScript API yet but that will be added in the near future. This work was graciously sponsored by GitHub, Inc.
Diffstat (limited to 'src/pipe_wrap.h')
-rw-r--r--src/pipe_wrap.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/pipe_wrap.h b/src/pipe_wrap.h
index 944835774d0..89330fc7241 100644
--- a/src/pipe_wrap.h
+++ b/src/pipe_wrap.h
@@ -21,6 +21,8 @@
#ifndef SRC_PIPE_WRAP_H_
#define SRC_PIPE_WRAP_H_
+
+#include "env.h"
#include "stream_wrap.h"
namespace node {
@@ -29,12 +31,14 @@ class PipeWrap : public StreamWrap {
public:
uv_pipe_t* UVHandle();
- static v8::Local<v8::Object> Instantiate();
+ static v8::Local<v8::Object> Instantiate(Environment* env);
static PipeWrap* Unwrap(v8::Local<v8::Object> obj);
- static void Initialize(v8::Handle<v8::Object> target);
+ static void Initialize(v8::Handle<v8::Object> target,
+ v8::Handle<v8::Value> unused,
+ v8::Handle<v8::Context> context);
private:
- PipeWrap(v8::Handle<v8::Object> object, bool ipc);
+ PipeWrap(Environment* env, v8::Handle<v8::Object> object, bool ipc);
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Bind(const v8::FunctionCallbackInfo<v8::Value>& args);