Offload functions to worker threads with shared memory primitives for Node.js.
8
fork

Configure Feed

Select the types of activity you want to include in your feed.

at e46aca05dbf9a2204886d23f7ae3b34883f4e5c6 28 lines 832 B view raw
1import { registerSync } from './reconstruct.ts'; 2import type { Loadable } from './loadable.ts'; 3 4export class Uint64 implements Loadable<bigint> { 5 static readonly byteSize = 8; 6 static readonly byteAlignment = 8; 7 private readonly view: BigUint64Array; 8 9 constructor(buffer?: SharedArrayBuffer, byteOffset?: number) { 10 const buf = buffer ?? new SharedArrayBuffer(8); 11 const offset = byteOffset ?? 0; 12 this.view = new BigUint64Array(buf, offset, 1); 13 } 14 15 load(): bigint { 16 return this.view[0]; 17 } 18 19 store(value: bigint): void { 20 this.view[0] = value; 21 } 22 23 [Symbol.for('moroutine.shared')](): { tag: string; buffer: SharedArrayBuffer; byteOffset: number } { 24 return { tag: 'Uint64', buffer: this.view.buffer as SharedArrayBuffer, byteOffset: this.view.byteOffset }; 25 } 26} 27 28registerSync('Uint64', Uint64);