pub struct ThreadState { /* private fields */ }Expand description
State held by ThreadPool for sending and receiving TaskInFlights
between it and a thread.
Returned from
Platform::spawn_pool_thread,
multiple of these are used to create a ThreadPool.
Implementations§
Source§impl ThreadState
impl ThreadState
Sourcepub fn new(
sender_to_thread: TaskSender,
receiver_from_thread: TaskReceiver,
) -> ThreadState
pub fn new( sender_to_thread: TaskSender, receiver_from_thread: TaskReceiver, ) -> ThreadState
Creates a new ThreadState from the relevant channel endpoints.
sender_to_thread is used to send tasks to the thread, while
receiver_from_thread is used to receive finished tasks, so there
should be two channels for each thread.
To implement a simple single-threaded ThreadPool, the sender and
receiver of just one channel could be passed here, in which case
ThreadPool will run the task when joining that task in
ThreadPool::join_task.
Auto Trait Implementations§
impl Freeze for ThreadState
impl !RefUnwindSafe for ThreadState
impl Send for ThreadState
impl Sync for ThreadState
impl Unpin for ThreadState
impl !UnwindSafe for ThreadState
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