pub struct Thread { /* private fields */ }
Expand description
The state for the thread pool thread for the currently running CPU.
Implementations§
Source§impl Thread
impl Thread
Sourcepub fn with_driver<R>(&self, f: impl FnOnce(&ThreadpoolDriver) -> R) -> R
pub fn with_driver<R>(&self, f: impl FnOnce(&ThreadpoolDriver) -> R) -> R
Calls f
with the driver for the current thread.
Sourcepub fn set_idle_task<F>(&self, f: F)where
F: 'static + Send + AsyncFnOnce(IdleControl),
pub fn set_idle_task<F>(&self, f: F)where
F: 'static + Send + AsyncFnOnce(IdleControl),
Sets the idle task to run. The task is returned by f
, which receives
the file descriptor of the IO ring.
The idle task is run before waiting on the IO ring. The idle task can
block synchronously by first calling [IdleControl::pre_block
], and
then by polling on the IO ring while the task blocks.
Sourcepub fn try_set_affinity(&self) -> Result<bool, SetAffinityError>
pub fn try_set_affinity(&self) -> Result<bool, SetAffinityError>
Tries to set the affinity to this thread’s intended CPU, if it has not
already been set. Returns Ok(false)
if the intended CPU is still
offline.
Sourcepub fn first_task(&self) -> Option<TaskInfo>
pub fn first_task(&self) -> Option<TaskInfo>
Returns the that caused this thread to spawn.
Returns None
if the thread was spawned to issue IO.
Trait Implementations§
Source§impl SpawnLocal for Thread
impl SpawnLocal for Thread
Source§fn scheduler_local(&self, metadata: &TaskMetadata) -> Arc<dyn Schedule>
fn scheduler_local(&self, metadata: &TaskMetadata) -> Arc<dyn Schedule>
Gets a scheduler for a new task.
Source§fn spawn_local<T>(
&self,
name: impl Into<Arc<str>>,
fut: impl Future<Output = T> + 'static,
) -> Task<T, TaskMetadata>where
T: 'static,
Self: Sized,
fn spawn_local<T>(
&self,
name: impl Into<Arc<str>>,
fut: impl Future<Output = T> + 'static,
) -> Task<T, TaskMetadata>where
T: 'static,
Self: Sized,
Spawns a task.
impl Copy for Thread
Auto Trait Implementations§
impl Freeze for Thread
impl RefUnwindSafe for Thread
impl !Send for Thread
impl !Sync for Thread
impl Unpin for Thread
impl UnwindSafe for Thread
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