Struct base::worker_thread::WorkerThread
source · pub struct WorkerThread<T: Send + 'static> {
worker: Option<(Event, JoinHandle<T>)>,
}
Expand description
Wrapper object for creating a worker thread that can be stopped by signaling an event.
Fields§
§worker: Option<(Event, JoinHandle<T>)>
Implementations§
source§impl<T: Send + 'static> WorkerThread<T>
impl<T: Send + 'static> WorkerThread<T>
sourcepub fn start<F>(thread_name: impl Into<String>, thread_func: F) -> Self
pub fn start<F>(thread_name: impl Into<String>, thread_func: F) -> Self
Starts a worker thread named thread_name
running the thread_func
function.
The thread_func
implementation must monitor the provided Event
and return from the
thread when it is signaled.
Call stop()
to stop the thread.
sourcepub fn stop(self) -> T
pub fn stop(self) -> T
Stops the worker thread.
Returns the value returned by the function running in the thread.
Trait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for WorkerThread<T>
impl<T> Send for WorkerThread<T>
impl<T> Sync for WorkerThread<T>
impl<T> Unpin for WorkerThread<T>
impl<T> !UnwindSafe for WorkerThread<T>
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