forked from denoland/deno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(core): Allow multiple overflown responses in single poll (de…
…noland#9433) This commit rewrites "JsRuntime::poll" function to fix a corner case that might caused "overflown_response" to be overwritten by other overflown response. The logic has been changed to allow returning multiple overflown response alongside responses from shared queue.
- Loading branch information
Showing
6 changed files
with
156 additions
and
48 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
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,14 @@ | ||
// Copyright 2020 the Deno authors. All rights reserved. MIT license. | ||
|
||
const dataSmall = ""; | ||
const dataLarge = "x".repeat(10 * 1024); | ||
|
||
onmessage = function (e) { | ||
for (let i = 0; i <= 10; i++) { | ||
if (i % 2 == 0) { | ||
postMessage(dataLarge); | ||
} else { | ||
postMessage(dataSmall); | ||
} | ||
} | ||
}; |
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,35 @@ | ||
// Copyright 2020 the Deno authors. All rights reserved. MIT license. | ||
|
||
// deno-lint-ignore-file | ||
|
||
import { deferred } from "../../test_util/std/async/deferred.ts"; | ||
|
||
function oneWorker(i: any): Promise<void> { | ||
return new Promise<void>((resolve) => { | ||
let countDown = 10; | ||
const worker = new Worker( | ||
new URL("workers/large_message_worker.js", import.meta.url).href, | ||
{ type: "module" }, | ||
); | ||
worker.onmessage = (e): void => { | ||
if (countDown > 0) { | ||
countDown--; | ||
return; | ||
} | ||
worker.terminate(); | ||
resolve(); | ||
}; | ||
worker.postMessage("hi " + i); | ||
}); | ||
} | ||
|
||
function bench(): Promise<any> { | ||
let promises = []; | ||
for (let i = 0; i < 50; i++) { | ||
promises.push(oneWorker(i)); | ||
} | ||
|
||
return Promise.all(promises); | ||
} | ||
|
||
bench(); |
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