mirror of
https://github.com/denoland/deno.git
synced 2024-11-26 16:09:27 -05:00
47f318230f
Follow up to https://github.com/denoland/deno/pull/22815
17 lines
563 B
JavaScript
17 lines
563 B
JavaScript
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
import { parentPort, workerData } from "node:worker_threads";
|
|
import { once } from "node:events";
|
|
|
|
async function message(expectedMessage) {
|
|
const [message] = await once(parentPort, "message");
|
|
if (message !== expectedMessage) {
|
|
console.log(`Expected the message "${expectedMessage}", but got`, message);
|
|
// fail test
|
|
parentPort.close();
|
|
}
|
|
}
|
|
|
|
const uint = new Uint8Array(workerData.sharedArrayBuffer);
|
|
uint[0]++;
|
|
await message("Hello");
|
|
parentPort.postMessage("Hello");
|