NET-Web-API-w-Angular/my-app/node_modules/piscina/test/fixtures/wait-for-others.ts

12 lines
319 B
TypeScript
Raw Normal View History

2024-02-09 00:38:41 +00:00
import { threadId } from 'worker_threads';
module.exports = async function ([i32array, n]) {
Atomics.add(i32array, 0, 1);
Atomics.notify(i32array, 0, Infinity);
let lastSeenValue;
while ((lastSeenValue = Atomics.load(i32array, 0)) < n) {
Atomics.wait(i32array, 0, lastSeenValue);
}
return threadId;
};