Struct tokio::runtime::scheduler::multi_thread::queue::Local

source ·
pub(crate) struct Local<T: 'static> {
    inner: Arc<Inner<T>>,
}
Expand description

Producer handle. May only be used from a single thread.

Fields§

§inner: Arc<Inner<T>>

Implementations§

source§

impl<T> Local<T>

source

pub(crate) fn len(&self) -> usize

Returns the number of entries in the queue

source

pub(crate) fn remaining_slots(&self) -> usize

How many tasks can be pushed into the queue

source

pub(crate) fn max_capacity(&self) -> usize

source

pub(crate) fn has_tasks(&self) -> bool

Returns false if there are any entries in the queue

Separate to is_stealable so that refactors of is_stealable to “protect” some tasks from stealing won’t affect this

source

pub(crate) fn push_back( &mut self, tasks: impl ExactSizeIterator<Item = Notified<T>>, )

Pushes a batch of tasks to the back of the queue. All tasks must fit in the local queue.

§Panics

The method panics if there is not enough capacity to fit in the queue.

source

pub(crate) fn push_back_or_overflow<O: Overflow<T>>( &mut self, task: Notified<T>, overflow: &O, stats: &mut Stats, )

Pushes a task to the back of the local queue, if there is not enough capacity in the queue, this triggers the overflow operation.

When the queue overflows, half of the current contents of the queue is moved to the given Injection queue. This frees up capacity for more tasks to be pushed into the local queue.

source

fn push_back_finish(&self, task: Notified<T>, tail: u32)

source

fn push_overflow<O: Overflow<T>>( &mut self, task: Notified<T>, head: u32, tail: u32, overflow: &O, stats: &mut Stats, ) -> Result<(), Notified<T>>

Moves a batch of tasks into the inject queue.

This will temporarily make some of the tasks unavailable to stealers. Once push_overflow is done, a notification is sent out, so if other workers “missed” some of the tasks during a steal, they will get another opportunity.

source

pub(crate) fn pop(&mut self) -> Option<Notified<T>>

Pops a task from the local queue.

Trait Implementations§

source§

impl<T> Drop for Local<T>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Local<T>

§

impl<T> !RefUnwindSafe for Local<T>

§

impl<T> Send for Local<T>

§

impl<T> Sync for Local<T>

§

impl<T> Unpin for Local<T>

§

impl<T> !UnwindSafe for Local<T>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.