Struct bp3d_threads::ThreadPool [−][src]
pub struct ThreadPool<'env, Manager: ThreadManager<'env>, T: Send + 'static> { /* fields omitted */ }Expand description
Core thread pool.
Implementations
Schedule a new task to run.
Returns true if the task was successfully scheduled, false otherwise.
The task execution order is not guaranteed, however the task index is guaranteed to be the order of the call to dispatch.
If a task panics it will leave a dead thread in the corresponding slot until .join() is called.
Arguments
manager: the thread manager to spawn a new thread if needed.f: the task function to execute.
returns: bool
Examples
use bp3d_threads::UnscopedThreadManager;
use bp3d_threads::ThreadPool;
let manager = UnscopedThreadManager::new();
let mut pool: ThreadPool<UnscopedThreadManager, ()> = ThreadPool::new(4);
pool.dispatch(&manager, |_| ());Returns true if this thread pool is idle.
An idle thread pool does neither have running threads nor waiting tasks but may still have waiting results to poll.
Poll a result from this thread pool if any, returns None if no result is available.