Constructor
new Parent(threadProcessPath)
Manage communication between socket wrapper and worker thread
Parameters:
Name | Type | Description |
---|---|---|
threadProcessPath | string | path to the thread process |
Members
_resolveApply :Object.<string, function()>
Type:
- Object.<string, function()>
callbacks :Object.<string, function()>
Type:
- Object.<string, function()>
socketWrappers :Array.<SocketWrapper>
current socket wrapper connected in thread
Type:
- Array.<SocketWrapper>
worker :workerThreads.Worker
worker
Type:
- workerThreads.
Worker
Methods
addSocketWrapper(socketWrapper)
Add a socket wrapper in this thread
Parameters:
Name | Type | Description |
---|---|---|
socketWrapper | SocketWrapper | socket wrapper to add |
apply(msgType, data) → {Promise}
Same as this.post
but return a promise resolving when thread child has applied message
Parameters:
Name | Type | Description |
---|---|---|
msgType | string | message type |
data | object | seriablizable data |
Returns:
- promise resolving when thread child has applied message
- Type:
- Promise
on(msgType, callback)
Receive message from child thread
Parameters:
Name | Type | Description |
---|---|---|
msgType | string | message type |
callback | function | callback to apply |
post(msgType, data)
Send Message to child thread
Parameters:
Name | Type | Description |
---|---|---|
msgType | string | message type |
data | object | seriablizable data |
removeSocketWrapper(socketWrapper) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
socketWrapper | SocketWrapper | socket wrapper to remove |
Returns:
- true if removed
- Type:
- boolean