Skip to content

Instantly share code, notes, and snippets.

@WimJongeneel
Created January 12, 2020 14:31
Show Gist options
  • Save WimJongeneel/51328a52000b5700431702336145e6b8 to your computer and use it in GitHub Desktop.
Save WimJongeneel/51328a52000b5700431702336145e6b8 to your computer and use it in GitHub Desktop.
import * as wp from 'workerpool'
const workerpool = wp.pool()
net.createServer()
.listen(PORT, IP, BACKLOG)
.on('connection', socket => {
console.log('new connection')
socket
.on('data', buffer => {
console.log('data')
workerpool.exec(() => fibonacci(100), [])
.then(res => {
socket.write(res)
console.log('done with connection')
socket.end()
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment