-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementors of `deno_core::JsRuntime` might want to do additional actions during each turn of event loop, eg. `deno_runtime::Worker` polls inspector, `deno_runtime::WebWorker` receives/dispatches messages from/to worker host. Previously `JsRuntime::mod_evaluate` was implemented in such fashion that it only polled `JsRuntime`'s event loop. This behavior turned out to be wrong in the example of `WebWorker` which couldn't receive/dispatch messages because its implementation of event loop was never called. This commit rewrites "mod_evaluate" to return a handle to receiver that resolves when module's promise resolves. It is now implementors responsibility to poll event loop after calling `mod_evaluate`.
- Loading branch information
1 parent
660f75e
commit e924bbd
Showing
6 changed files
with
95 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. | ||
|
||
import { serve } from "../../std/http/server.ts"; | ||
|
||
const server = serve({ port: 8080 }); | ||
|
||
self.onmessage = (e: MessageEvent) => { | ||
console.log("TLA worker received message", e.data); | ||
}; | ||
|
||
self.postMessage("hello"); | ||
|
||
for await (const _r of server) { | ||
// pass | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters