1.0.1 • Published 6 years ago

@anzerr/thread v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

Intro

Test to understand how the new 'worker_threads' works with SharedArrayBuffer.

Install

npm install --save git+https://github.com/anzerr/worker_threads.node.git
npm install --save @anzerr/thread.node

Example

const {Executors} = require('thread.node');

let pool = Executors.singleThreadPool();

const buffer = new SharedArrayBuffer(16);

pool.submit(async (d) => (new Int32Array(d)[0] = 42), buffer).then(() => {
	return pool.submit(async (d) => new Int32Array(d)[0], buffer);
}).then((result) => {
	console.log(result);
	return pool.close();
}).then(() => {
	console.log('done');
});