Created
June 25, 2018 09:14
-
-
Save chnbohwr/8622f4e2a7235391aef954920ab521ed to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Worker } = require('worker_threads'); | |
const path = require('path'); | |
const buffer = new SharedArrayBuffer(1); | |
const worker = new Worker(path.resolve('./worker.js')); | |
worker.on('message', () => { | |
// check buffer was changed ? | |
const int8Array = new Int8Array(buffer); | |
console.log(`main thread buffer: ${int8Array[0]}`) | |
}); | |
worker.postMessage(buffer); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment