Open DrSensor opened 2 years ago
/** @path ./nusa/current/thread.js */
export let /** @type number */ count
export let /** @type string */ name
/** @path ./nusa/current.js */
import * as w from "./current/worker.js"
export const worker = {
get count() { return w.count },
get name() { return w.name },
/** @example ```js
for ( // auto-cast as count number
let i = (data.length / current.worker) - 1;
i !== 0; i--
) {
// heavy computation
}
// auto-cast as name string
console.debug(`thread ${current.worker}`)
```*/
[Symbol.toPrimitive](type) {
switch (type) {
case "number": return w.count
case "string": return w.name
default: throw "loose equal operator (==) is ambiguous"
}
},
}
@spawn
decorator then use single SharedArrayBuffer across thread)