Struct drone_core::fib::Chain [−][src]
pub struct Chain { /* fields omitted */ }
A lock-free list of fibers.
Implementations
impl Chain
[src]
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]
&self
) -> Drain<'_, impl FnMut(*mut ListNode<Node<()>>) -> bool>
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 { chain.drain().for_each(drop); // 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"); } drain.for_each(drop);
Safety
This method must not be called again when the previous iterator is still alive.