nanolith
Version:
Multi-threading in no time with seamless TypeScript support.
74 lines (73 loc) • 1.96 kB
TypeScript
/**
* Message types that will only be sent from the parent thread
* to workers, and never the other way around.
*/
export declare const enum ParentThreadMessageType {
/**
* When sending a message to a worker from the main thread.
*/
Message = 0,
/**
* When calling a task in a service worker.
*/
Call = 1,
/**
* When posting a message to a service worker
* notifying it to exit its process immediately.
*/
Terminate = 2,
/**
* When passing `Messenger` objects to workers.
*/
MessengerTransfer = 3
}
/**
* Message types that will only be sent from workers over to
* the parent thread, and never the other way around.
*/
export declare const enum WorkerMessageType {
/**
* When sending a message from a worker to
* the parent thread.
*/
Message = 0,
/**
* When a task worker has returned a
* value and posting it back to the parent thread.
*/
TaskReturn = 1,
/**
* When a task worker has failed and
* an error has been thrown.
*/
TaskError = 2,
/**
* When a called task in a service worker has
* returned a value and posting it back to the parent thread.
*/
CallReturn = 3,
/**
* When a called task in a service worker has
* failed and posting the error back to the parent thread.
*/
CallError = 4,
/**
* When notifying the parent thread that a `Messenger`
* object has successfully been sent.
*/
MessengerTransferSuccess = 5,
/**
* When a service worker throws an exception and the parent
* thread must be notified about it.
*/
WorkerException = 6,
/**
* To notify the parent thread that a service worker has
* completed initialization and that it's ready to go.
*/
Initialized = 7,
/**
* For sending messages to the main thread notifying that a service has exited.
*/
Exit = 8
}