You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

11 lines
319 B

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;
};