summaryrefslogtreecommitdiff
path: root/src/stream_wrap.h
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2013-08-11 00:26:11 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2013-09-06 05:51:42 +0200
commit756b6222956b5d25b2e7db81f4e79033a3a4d20e (patch)
treeeb03b6f0bf33c36e011858c4a31b10a6eaadfc19 /src/stream_wrap.h
parent81655a224a36948291e1f21f03273b5b604b7e6a (diff)
downloadandroid-node-v8-756b6222956b5d25b2e7db81f4e79033a3a4d20e.tar.gz
android-node-v8-756b6222956b5d25b2e7db81f4e79033a3a4d20e.tar.bz2
android-node-v8-756b6222956b5d25b2e7db81f4e79033a3a4d20e.zip
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/stream_wrap.h')
-rw-r--r--src/stream_wrap.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/stream_wrap.h b/src/stream_wrap.h
index 6731fdbf75..26fb5d5ef6 100644
--- a/src/stream_wrap.h
+++ b/src/stream_wrap.h
@@ -22,11 +22,11 @@
#ifndef SRC_STREAM_WRAP_H_
#define SRC_STREAM_WRAP_H_
-#include "v8.h"
-#include "node.h"
+#include "env.h"
#include "handle_wrap.h"
#include "req_wrap.h"
#include "string_bytes.h"
+#include "v8.h"
namespace node {
@@ -37,8 +37,8 @@ typedef class ReqWrap<uv_shutdown_t> ShutdownWrap;
class WriteWrap: public ReqWrap<uv_write_t> {
public:
- WriteWrap(v8::Local<v8::Object> obj, StreamWrap* wrap)
- : ReqWrap<uv_write_t>(obj)
+ WriteWrap(Environment* env, v8::Local<v8::Object> obj, StreamWrap* wrap)
+ : ReqWrap<uv_write_t>(env, obj)
, wrap_(wrap) {
}
@@ -108,8 +108,6 @@ class StreamWrap : public HandleWrap {
delete old;
}
- static void Initialize(v8::Handle<v8::Object> target);
-
static void GetFD(v8::Local<v8::String>,
const v8::PropertyCallbackInfo<v8::Value>&);
@@ -148,7 +146,9 @@ class StreamWrap : public HandleWrap {
protected:
static size_t WriteBuffer(v8::Handle<v8::Value> val, uv_buf_t* buf);
- StreamWrap(v8::Handle<v8::Object> object, uv_stream_t* stream);
+ StreamWrap(Environment* env,
+ v8::Local<v8::Object> object,
+ uv_stream_t* stream);
~StreamWrap() {
if (callbacks_ != &default_callbacks_) {