Parent

  • workerThreads wrapper, different event can be send/receive by the thread

Constructor

new Parent(threadProcessPath)

Manage communication between socket wrapper and worker thread

Parameters:
NameTypeDescription
threadProcessPathstring

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:
NameTypeDescription
socketWrapperSocketWrapper

socket wrapper to add

apply(msgType, data) → {Promise}

Same as this.post but return a promise resolving when thread child has applied message

Parameters:
NameTypeDescription
msgTypestring

message type

dataobject

seriablizable data

Returns:
  • promise resolving when thread child has applied message
Type: 
Promise

on(msgType, callback)

Receive message from child thread

Parameters:
NameTypeDescription
msgTypestring

message type

callbackfunction

callback to apply

post(msgType, data)

Send Message to child thread

Parameters:
NameTypeDescription
msgTypestring

message type

dataobject

seriablizable data

removeSocketWrapper(socketWrapper) → {boolean}

Parameters:
NameTypeDescription
socketWrapperSocketWrapper

socket wrapper to remove

Returns:
  • true if removed
Type: 
boolean