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/node_buffer.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/node_buffer.h')
-rw-r--r--src/node_buffer.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/node_buffer.h b/src/node_buffer.h
index ca9a135e9df..78e6e42f6cb 100644
--- a/src/node_buffer.h
+++ b/src/node_buffer.h
@@ -26,6 +26,10 @@
#include "smalloc.h"
#include "v8.h"
+#if defined(NODE_WANT_INTERNALS)
+#include "env.h"
+#endif // defined(NODE_WANT_INTERNALS)
+
namespace node {
namespace Buffer {
@@ -56,6 +60,20 @@ NODE_EXTERN v8::Local<v8::Object> New(char* data,
// TODO(trevnorris): should be New() for consistency
NODE_EXTERN v8::Local<v8::Object> Use(char* data, uint32_t len);
+// Internal. Not for public consumption. We can't define these in
+// src/node_internals.h due to a circular dependency issue with
+// the smalloc.h and node_internals.h headers.
+#if defined(NODE_WANT_INTERNALS)
+v8::Local<v8::Object> New(Environment* env, size_t size);
+v8::Local<v8::Object> New(Environment* env, const char* data, size_t len);
+v8::Local<v8::Object> New(Environment* env,
+ char* data,
+ size_t length,
+ smalloc::FreeCallback callback,
+ void* hint);
+v8::Local<v8::Object> Use(Environment* env, char* data, uint32_t length);
+#endif // defined(NODE_WANT_INTERNALS)
+
} // namespace Buffer
} // namespace node