new Worker(Options)
Creates a Worker
Parameters:
Name | Type | Description |
---|---|---|
Options |
Object |
- Source:
Methods
add(task)
Add a task to the worker
Parameters:
Name | Type | Description |
---|---|---|
task |
Task |
- Source:
Listens to Events:
- Worker.task~event:exit
Returns:
this
kill(Signal)
Send a signal to tasks
Parameters:
Name | Type | Description |
---|---|---|
Signal |
Number |
- Source:
- See:
-
- ChildProcess#signal
onExit(name) → {function}
Registers an exit listener
Parameters:
Name | Type | Description |
---|---|---|
name |
String | the task name |
- Source:
Returns:
The listener that deletes an ended task
- Type
- function
remove(name) → {Promise}
Removes a worker by name
Parameters:
Name | Type | Description |
---|---|---|
name |
String |
- Source:
Returns:
resolves when the task exit event is fired
- Type
- Promise
send() → {Promise}
send a message on every task
- Source:
Returns:
resolves when every task received the message
- Type
- Promise
start(Signal)
Starts every tasks
Parameters:
Name | Type | Description |
---|---|---|
Signal |
Number |
- Source:
- See:
-
- ChildProcess#signal
task(name) → {Task}
Get a task by name
Parameters:
Name | Type | Description |
---|---|---|
name |
String |
- Source:
Returns:
- Type
- Task