summaryrefslogtreecommitdiff
path: root/src/uv.cc
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/uv.cc
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/uv.cc')
-rw-r--r--src/uv.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/uv.cc b/src/uv.cc
index 2da32d4b7e..2759d29671 100644
--- a/src/uv.cc
+++ b/src/uv.cc
@@ -25,6 +25,7 @@
namespace node {
namespace uv {
+using v8::Context;
using v8::FunctionCallbackInfo;
using v8::FunctionTemplate;
using v8::Handle;
@@ -44,8 +45,9 @@ void ErrName(const FunctionCallbackInfo<Value>& args) {
}
-void Initialize(Handle<Object> target) {
- v8::HandleScope handle_scope(node_isolate);
+void Initialize(Handle<Object> target,
+ Handle<Value> unused,
+ Handle<Context> context) {
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "errname"),
FunctionTemplate::New(ErrName)->GetFunction());
#define V(name, _) \
@@ -59,4 +61,4 @@ void Initialize(Handle<Object> target) {
} // namespace uv
} // namespace node
-NODE_MODULE(node_uv, node::uv::Initialize)
+NODE_MODULE_CONTEXT_AWARE(node_uv, node::uv::Initialize)