Struct pargraph::executors::multi_thread::MultiThreadExecutor
source · pub struct MultiThreadExecutor { /* private fields */ }
Expand description
Execute graph operators on multiple threads.
This executor will create clones of the operator for each worker thread. Therefore, the operators should usually be cheap to clone. For example they can include large shared data as a reference. Cloning the operators also allows them to keep thread-local data, if necessary.
Implementations§
source§impl MultiThreadExecutor
impl MultiThreadExecutor
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new multi-threaded executor. Automatically determine the number of threads.
sourcepub fn with_num_threads(self, num_threads: NonZeroUsize) -> Self
pub fn with_num_threads(self, num_threads: NonZeroUsize) -> Self
Set the number of threads to be used.
sourcepub fn run_node_labelling<Wl, Op, G>(
&self,
initial_worklist: Wl,
operator: Op,
graph: G,
)where
Wl: Worklist<Op::WorkItem>,
Wl::Channel: Send,
Op: LabellingOperator<G> + Clone + Send,
G: GraphBase + DataMap + Sync,
G::NodeWeight: BorrowDataCell<UserData = Op::NodeWeight>,
Op::WorkItem: Copy,
pub fn run_node_labelling<Wl, Op, G>(
&self,
initial_worklist: Wl,
operator: Op,
graph: G,
)where
Wl: Worklist<Op::WorkItem>,
Wl::Channel: Send,
Op: LabellingOperator<G> + Clone + Send,
G: GraphBase + DataMap + Sync,
G::NodeWeight: BorrowDataCell<UserData = Op::NodeWeight>,
Op::WorkItem: Copy,
Run an algorithm which modifies node labels but keeps the topology unchanged.
sourcepub fn run_readonly<Wl, Op, G>(
&self,
initial_worklist: Wl,
operator: Op,
graph: G,
)
pub fn run_readonly<Wl, Op, G>( &self, initial_worklist: Wl, operator: Op, graph: G, )
Run an algorithm which does not need explicit mutable access to the graph elements. It can, of course, modify node and edge weights by using interior mutability together with an appropriate locking mechansim or atomic operations.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MultiThreadExecutor
impl RefUnwindSafe for MultiThreadExecutor
impl Send for MultiThreadExecutor
impl Sync for MultiThreadExecutor
impl Unpin for MultiThreadExecutor
impl UnwindSafe for MultiThreadExecutor
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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