Struct tokio::runtime::scheduler::inject::shared::Shared

source ·
pub(crate) struct Shared<T: 'static> {
    pub(super) len: AtomicUsize,
    _p: PhantomData<T>,
}

Fields§

§len: AtomicUsize

Number of pending tasks in the queue. This helps prevent unnecessary locking in the hot path.

§_p: PhantomData<T>

Implementations§

source§

impl<T: 'static> Shared<T>

source

pub(crate) fn new() -> (Shared<T>, Synced)

source

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

source

pub(crate) fn is_closed(&self, synced: &Synced) -> bool

source

pub(crate) fn close(&self, synced: &mut Synced) -> bool

Closes the injection queue, returns true if the queue is open when the transition is made.

source

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

source

pub(crate) unsafe fn push(&self, synced: &mut Synced, task: Notified<T>)

Pushes a value into the queue.

This does nothing if the queue is closed.

§Safety

Must be called with the same Synced instance returned by Inject::new

source

pub(crate) unsafe fn pop(&self, synced: &mut Synced) -> Option<Notified<T>>

Pop a value from the queue.

§Safety

Must be called with the same Synced instance returned by Inject::new

source

pub(crate) unsafe fn pop_n<'a>( &'a self, synced: &'a mut Synced, n: usize, ) -> Pop<'a, T>

Pop n values from the queue

§Safety

Must be called with the same Synced instance returned by Inject::new

source§

impl<T: 'static> Shared<T>

source

pub(crate) unsafe fn push_batch<L, I>(&self, shared: L, iter: I)
where L: Lock<Synced>, I: Iterator<Item = Notified<T>>,

Pushes several values into the queue.

§Safety

Must be called with the same Synced instance returned by Inject::new

source

unsafe fn push_batch_inner<L>( &self, shared: L, batch_head: RawTask, batch_tail: RawTask, num: usize, )
where L: Lock<Synced>,

Inserts several tasks that have been linked together into the queue.

The provided head and tail may be be the same task. In this case, a single task is inserted.

Trait Implementations§

source§

impl<T> Send for Shared<T>

source§

impl<T> Sync for Shared<T>

Auto Trait Implementations§

§

impl<T> !Freeze for Shared<T>

§

impl<T> RefUnwindSafe for Shared<T>
where T: RefUnwindSafe,

§

impl<T> Unpin for Shared<T>
where T: Unpin,

§

impl<T> UnwindSafe for Shared<T>
where T: UnwindSafe,

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>,

source§

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>,

source§

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.