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
Available on crate feature rayon
only.
pub fn with_rayon_thread_pool(pool: Arc<ThreadPool>) -> JxlThreadPool
rayon
only.Creates a thread pool backed by Rayon ThreadPool
.
Sourcepub fn rayon(num_threads_requested: Option<usize>) -> JxlThreadPool
Available on crate feature rayon
only.
pub fn rayon(num_threads_requested: Option<usize>) -> JxlThreadPool
rayon
only.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>
Available on crate feature rayon
only.
pub fn as_rayon_pool(&self) -> Option<&ThreadPool>
rayon
only.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§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