Skip to content

Commit

Permalink
src: add multi-context support
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bnoordhuis committed Sep 6, 2013
1 parent 81655a2 commit 756b622
Show file tree
Hide file tree
Showing 45 changed files with 2,520 additions and 1,704 deletions.
5 changes: 5 additions & 0 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@
'src/udp_wrap.cc',
'src/uv.cc',
# headers to make for a more pleasant IDE experience
'src/env.h',
'src/env-inl.h',
'src/handle_wrap.h',
'src/node.h',
'src/node_buffer.h',
Expand All @@ -124,6 +126,7 @@
'src/node_extensions.h',
'src/node_file.h',
'src/node_http_parser.h',
'src/node_internals.h',
'src/node_javascript.h',
'src/node_root_certs.h',
'src/node_version.h',
Expand All @@ -139,6 +142,8 @@
'src/string_bytes.h',
'src/stream_wrap.h',
'src/tree.h',
'src/util.h',
'src/util-inl.h',
'deps/http_parser/http_parser.h',
'<(SHARED_INTERMEDIATE_DIR)/node_natives.h',
# javascript files to make for an even more pleasant IDE experience
Expand Down
Loading

0 comments on commit 756b622

Please sign in to comment.