Skip to content

Instantly share code, notes, and snippets.

@caesaneer
Created August 18, 2019 22:17
Show Gist options
  • Save caesaneer/769f27865f2eaec48f79b173a4382f2d to your computer and use it in GitHub Desktop.
Save caesaneer/769f27865f2eaec48f79b173a4382f2d to your computer and use it in GitHub Desktop.
Part 2 - Worker Threads - Worker.js
// ════════════════════════════════════════════════════════════════════════════════════════════════╡
const { parentPort, workerData } = require('worker_threads')
const bench = require('./bench')
// ════════════════════════════════════════════════════════════════════════════════════════════════╡
parentPort.on('message', () => {
const result = bench(100)
parentPort.postMessage(result)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment