diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2019-03-14 19:17:52 -0400 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-03-18 17:17:08 -0400 |
commit | 44773c9b0fe4ae90089c87aa46d049a0a58cccce (patch) | |
tree | 34bd66dc66dd59b9acd4bb0a48ea576610187e05 /core/shared_queue.js | |
parent | 33438b83a2a2597c2b9918475dd5362faa5c1728 (diff) |
Integrate //core into existing code base
This disables a few tests which are broken still:
- tests/error_004_missing_module.test
- tests/error_005_missing_dynamic_import.test
- tests/error_006_import_ext_failure.test
- repl_test test_set_timeout
- repl_test test_async_op
- repl_test test_set_timeout_interlaced
- all of permission_prompt_test
Diffstat (limited to 'core/shared_queue.js')
-rw-r--r-- | core/shared_queue.js | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/core/shared_queue.js b/core/shared_queue.js index 756f86e72..6c9a0326f 100644 --- a/core/shared_queue.js +++ b/core/shared_queue.js @@ -11,10 +11,6 @@ let sharedBytes = null; let shared32 = null; - if (!window["Deno"]) { - window["Deno"] = {}; - } - function assert(cond) { if (!cond) { throw Error("assert"); @@ -105,10 +101,13 @@ asyncHandler = cb; } - function handleAsyncMsgFromRust() { - let buf; - while ((buf = shift()) != null) { + function handleAsyncMsgFromRust(buf) { + if (buf) { asyncHandler(buf); + } else { + while ((buf = shift()) != null) { + asyncHandler(buf); + } } } @@ -122,13 +121,26 @@ libdeno.recv(handleAsyncMsgFromRust); } - window.Deno._setAsyncHandler = setAsyncHandler; - window.Deno._sharedQueue = { - head, - numRecords, - size, - push, - shift + function dispatch(control, zeroCopy = null) { + // First try to push control to shared. + const success = push(control); + // If successful, don't use first argument of libdeno.send. + const arg0 = success ? null : control; + return libdeno.send(arg0, zeroCopy); + } + + assert(!window["DenoCore"]); + window["DenoCore"] = { + setAsyncHandler, + dispatch, + shared: { + head, + numRecords, + size, + push, + reset, + shift + } }; init(libdeno.shared); |