|
|
|
@ -44,14 +44,14 @@ fn spawn_for_lazy(recv: state::PendingReceiver<Job>) -> impl Iterator<Item = Joi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Spawn the thread pool and return handles to the spawned threads as a `Pool`.
|
|
|
|
|
#[inline] pub fn spawn_for_pool(recv: state::PendingReceiver<Job>) -> Pool
|
|
|
|
|
#[inline] fn spawn_for_pool(recv: state::PendingReceiver<Job>) -> Pool
|
|
|
|
|
{
|
|
|
|
|
spawn_for_lazy(recv).collect()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Spawn and then immediately wait on a thread pool to complete.
|
|
|
|
|
///
|
|
|
|
|
/// Has the same behaviour as `drop(spawn_for_pool(recv))` but skips a heap allocation.
|
|
|
|
|
/// Has the same behaviour as `drop(spawn_for_pool(recv))` but skips a potential heap allocation.
|
|
|
|
|
#[inline] pub fn spawn_for_and_join(recv: state::PendingReceiver<Job>)
|
|
|
|
|
{
|
|
|
|
|
join_all(spawn_for_lazy(recv));
|
|
|
|
@ -125,3 +125,12 @@ impl Drop for Pool
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Spawn a thread pool.
|
|
|
|
|
///
|
|
|
|
|
/// The pool can be spawned in different ways, this uses the default one.
|
|
|
|
|
/// The others are not made public except [`spawn_for_and_join`], as their behaviour differences are very subtle.
|
|
|
|
|
#[inline(always)] pub fn pool(recv: state::PendingReceiver<Job>) -> Pool
|
|
|
|
|
{
|
|
|
|
|
spawn_for_pool(recv)
|
|
|
|
|
}
|
|
|
|
|