Get/set the maximum number of idle threads kept alive.
Get/set the amount of time in milliseconds before an idle thread is destroyed.
If set to true the idle timeout will be calculated as idleThreadTimeout divideded by the number of idle threads at the moment. This may help save memory allocations but still keep reasonable amount of idle threads. Default is false, use |idleThreadTimeout| for all threads.
An optional listener that will be notified when a thread is created or destroyed in the course of the thread pool's operation.
A listener will only receive notifications about threads created after the listener is set so it is recommended that the consumer set the listener before dispatching the first event. A listener that receives an onThreadCreated() notification is guaranteed to always receive the corresponding onThreadShuttingDown() notification.
The thread pool takes ownership of the listener and releases it when the shutdown() method is called. Threads created after the listener is set will also take ownership of the listener so that the listener will be kept alive long enough to receive the guaranteed onThreadShuttingDown() notification.
Get/set the maximum number of threads allowed at one time in this pool.
Get/set the number of bytes reserved for the stack of all threads in the pool. By default this is nsIThreadManager::DEFAULT_STACK_SIZE.
Optional
aInstancePtr: objectA run time mechanism for interface discovery.
NS_OK if the interface is supported by the associated instance, NS_NOINTERFACE if it is not.
aInstancePtr must not be null.
[in] A requested interface IID
[out] A pointer to an interface pointer to receive the result.
Dispatch an event to this event target, but do not run it before delay milliseconds have passed. This function may be called from any thread.
NS_ERROR_INVALID_ARG Indicates that event is null.
NS_ERROR_UNEXPECTED Indicates that the thread is shutting down and has finished processing events, so this event would never run and has not been dispatched, or that delay is zero.
The alreadyAddrefed<> event to dispatch.
The delay (in ms) before running the event. If event does not rise to the top of the event queue before the delay has passed, it will be set aside to execute once the delay has passed. Otherwise, it will be executed immediately.
Version of Dispatch to expose to JS, which doesn't require an alreadyAddRefed<> (it will be converted to that internally)
NS_ERROR_INVALID_ARG Indicates that event is null.
NS_ERROR_UNEXPECTED Indicates that the thread is shutting down and has finished processing events, so this event would never run and has not been dispatched.
The (raw) event to dispatch.
The flags modifying event dispatch. The flags are described in detail below.
Dispatch an event to this event target. This function may be called from any thread, and it may be called re-entrantly.
NS_ERROR_INVALID_ARG Indicates that event is null.
NS_ERROR_UNEXPECTED Indicates that the thread is shutting down and has finished processing events, so this event would never run and has not been dispatched.
The alreadyAddRefed<> event to dispatch. NOTE that the event will be leaked if it fails to dispatch.
The flags modifying event dispatch. The flags are described in detail below.
Register an task to be run on this event target when it begins shutting down. Shutdown tasks may be run in any order, and this function may be called from any thread.
The event target may or may not continue accepting events during or after the shutdown task. The precise behaviour here depends on the event target.
NS_ERROR_INVALID_ARG Indicates that task is null.
NS_ERROR_NOT_IMPLEMENTED Indicates that this event target doesn't support shutdown tasks.
NS_ERROR_UNEXPECTED Indicates that the thread is already shutting down, and no longer accepting events.
The task to be registered to the target thread.
NOTE that unlike dispatch
, this will not leak the task if it fails.
Set the entire pool's QoS priority. If the priority has not changed, do nothing. Existing threads will update their QoS priority the next time they become active, and newly created threads will set this QoS priority upon creation.
Shutdown the thread pool. This method may not be executed from any thread in the thread pool. Instead, it is meant to be executed from another thread (usually the thread that created this thread pool). When this function returns, the thread pool and all of its threads will be shutdown, and it will no longer be possible to dispatch tasks to the thread pool.
As a side effect, events on the current thread will be processed.
Shutdown the thread pool, but only wait for aTimeoutMs. After the timeout expires, any threads that have not shutdown yet are leaked and will not block shutdown.
This method should only be used at during shutdown to cleanup threads that made blocking calls to code outside our control, and can't be safely terminated. We choose to leak them intentionally to avoid a shutdown hang.
Unregisters an task previously registered with registerShutdownTask. This function may be called from any thread.
NS_ERROR_INVALID_ARG Indicates that task is null.
NS_ERROR_NOT_IMPLEMENTED Indicates that this event target doesn't support shutdown tasks.
NS_ERROR_UNEXPECTED Indicates that the thread is already shutting down, and no longer accepting events, or that the shutdown task cannot be found.
The task previously registered with registerShutdownTask
Generated using TypeDoc
An interface to a thread pool. A thread pool creates a limited number of anonymous (unnamed) worker threads. An event dispatched to the thread pool will be run on the next available worker thread.