Closed marcgg closed 13 years ago
Hi Marc,
The 'args' option is intended to allow specifying node commandline flags (e.g. '--debug', '--crankshaft' or the like). It appears that you're trying to pass application-level positional parameters to the worker? If that's the case, this should really be done via message passing.
The idea here is to call the worker in the same way from the console or from the application. It would make testing the worker easier (no need for sending messages) and it would allow me to create it directly via a command.
Ah, gotcha.
That's an interesting use-case, but I think outside the scope of what I want to provide. If you don't want to maintain a fork, one option for you might be to create a wrapper script that would do nothing but launch a worker at the given path. In both cases, the worker code itself would interpret its first message as a list of arguments/initialization data. That's the standard Worker work-flow and the model that I'd like to preserve. Thanks for the feedback, though.
I've run into an issue when doing trying to create a worker with additional parameters:
var w = new Worker('/Users/me/webworkers/foo.js', {args: ["some","args"]});
With the current codebase, the args would be added before the rest of the arguments, causing multiple problems. I fixed it by pushing the new args after the current arguments. I also added a convenience method to access it from the child elements.
Let me know what you think