pub struct JxlThreadPool(/* private fields */);
Expand description
Thread pool wrapper.
This struct wraps internal thread pool implementation and provides interfaces to access it. If
rayon
feature is enabled, users can create an actual thread pool backed by Rayon; if not,
this struct won’t have any multithreading capability, and every spawn operation will just run
the given closure in place.
Implementations§
source§impl JxlThreadPool
impl JxlThreadPool
sourcepub const fn none() -> JxlThreadPool
pub const fn none() -> JxlThreadPool
Creates a “fake” thread pool without any multithreading capability.
Every spawn operation on this thread poll will just run the closure in current thread.
sourcepub fn with_rayon_thread_pool(pool: Arc<ThreadPool>) -> JxlThreadPool
pub fn with_rayon_thread_pool(pool: Arc<ThreadPool>) -> JxlThreadPool
Creates a thread pool backed by Rayon ThreadPool
.
sourcepub fn rayon(num_threads_requested: Option<usize>) -> JxlThreadPool
pub fn rayon(num_threads_requested: Option<usize>) -> JxlThreadPool
Creates a thread pool backed by Rayon.
If num_threads_requested
is None
or zero, this method queries available paralleism and
uses it.
sourcepub fn as_rayon_pool(&self) -> Option<&ThreadPool>
pub fn as_rayon_pool(&self) -> Option<&ThreadPool>
Returns the reference to Rayon thread pool, if exists.
sourcepub fn is_multithreaded(&self) -> bool
pub fn is_multithreaded(&self) -> bool
Returns if the thread pool is capable of multithreading.
source§impl JxlThreadPool
impl JxlThreadPool
sourcepub fn spawn(&self, op: impl FnOnce() + Send + 'static)
pub fn spawn(&self, op: impl FnOnce() + Send + 'static)
Runs the given closure on the thread pool.
sourcepub fn scope<'scope, R>(
&'scope self,
op: impl for<'r> FnOnce(JxlScope<'r, 'scope>) -> R + Send,
) -> Rwhere
R: Send,
pub fn scope<'scope, R>(
&'scope self,
op: impl for<'r> FnOnce(JxlScope<'r, 'scope>) -> R + Send,
) -> Rwhere
R: Send,
Creates a fork-join scope of tasks.
sourcepub fn for_each_vec<T>(&self, v: Vec<T>, op: impl Fn(T) + Send + Sync)where
T: Send,
pub fn for_each_vec<T>(&self, v: Vec<T>, op: impl Fn(T) + Send + Sync)where
T: Send,
Consumes the Vec
, and runs a job for each element of the Vec
.
sourcepub fn for_each_vec_with<T, U>(
&self,
v: Vec<T>,
init: U,
op: impl Fn(&mut U, T) + Send + Sync,
)
pub fn for_each_vec_with<T, U>( &self, v: Vec<T>, init: U, op: impl Fn(&mut U, T) + Send + Sync, )
Consumes the Vec
, and runs a job for each element of the Vec
.
Trait Implementations§
source§impl Clone for JxlThreadPool
impl Clone for JxlThreadPool
source§fn clone(&self) -> JxlThreadPool
fn clone(&self) -> JxlThreadPool
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for JxlThreadPool
impl !RefUnwindSafe for JxlThreadPool
impl Send for JxlThreadPool
impl Sync for JxlThreadPool
impl Unpin for JxlThreadPool
impl !UnwindSafe for JxlThreadPool
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more