Struct drone_core::fib::Chain[][src]

pub struct Chain { /* fields omitted */ }

A lock-free list of fibers.

Implementations

impl Chain[src]

pub const fn new() -> Self[src]

Creates an empty fiber chain.

pub fn add<F: RootFiber>(&self, fib: F)[src]

Adds a fiber first in the chain.

pub fn is_empty(&self) -> bool[src]

Returns true if the chain is empty.

pub unsafe fn drain(
    &self
) -> Drain<'_, impl FnMut(*mut ListNode<Node<()>>) -> bool>
[src]

Returns an iterator that advances each fiber in the chain, returning completed ones.

Examples

The returned iterator can be simply dropped, it’s destructor will drop all completed fibers:

use drone_core::fib::Chain;

let chain = Chain::new();
unsafe {
    drop(chain.drain()); // run the iterator and drop completed fibers
}

Check if there is at least one active fiber:

use drone_core::fib::Chain;

let chain = Chain::new();
let drain = unsafe { chain.drain() };
if drain.is_end() {
    println!("No active fibers to react to this interrupt");
}

Safety

This method must not be called again when the previous iterator is still alive.

Trait Implementations

impl Drop for Chain[src]

Auto Trait Implementations

impl Send for Chain

impl Sync for Chain

impl Unpin for Chain

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.