I tried to adopt the shell.cc sample from the V8 distribution package for my own purposes.
I want to spawn a web-worker to execute a long-running script, and execute:
var myWorker = new Worker("my_task.js");
But I receive the following error message:
(shell):1: ReferenceError: Worker is not defined
var myWorker = new Worker("my_task.js");
^
ReferenceError: Worker is not defined
at (shell):1:20
Is there a way to activate Web Workers in the V8 Engine?
Thank you in advance for any help on this issue!
I think you'd use the Child Process library for node or one of the other libraries that implements threading. As far as I know, web workers are a browser thing, not part of the standard node.js implementation and if you want that sort of API, you would need to use a third party library that implements something like that API.
Other useful references:
Lightweight Web Worker API implementation with native threads