Trait drone_core::thread::Thread
[−]
[src]
pub trait Thread: Sized + Sync + 'static { fn all() -> *mut [Self]; fn routines(&self) -> &RoutineStack; fn routines_mut(&mut self) -> &mut RoutineStack; fn task(&self) -> &TaskCell; fn preempted(&mut self) -> &mut usize; fn routine<G>(&self, g: G)
where
G: Generator<Yield = (), Return = ()>,
G: Send + 'static, { ... } fn routine_fn<F>(&self, f: F)
where
F: FnOnce(),
F: Send + 'static, { ... } fn future<G, T, E>(&self, g: G) -> RoutineFuture<T, E>
where
G: Generator<Yield = (), Return = Result<T, E>>,
G: Send + 'static,
T: Send + 'static,
E: Send + 'static, { ... } fn future_fn<F, T, E>(&self, f: F) -> RoutineFuture<T, E>
where
F: FnOnce() -> Result<T, E>,
F: Send + 'static,
T: Send + 'static,
E: Send + 'static, { ... } fn stream<G, E, O>(&self, overflow: O, g: G) -> RoutineStreamUnit<E>
where
G: Generator<Yield = Option<()>, Return = Result<Option<()>, E>>,
O: Fn() -> Result<(), E>,
G: Send + 'static,
E: Send + 'static,
O: Send + 'static, { ... } fn stream_skip<G, E>(&self, g: G) -> RoutineStreamUnit<E>
where
G: Generator<Yield = Option<()>, Return = Result<Option<()>, E>>,
G: Send + 'static,
E: Send + 'static, { ... } fn stream_ring<G, T, E, O>(
&self,
capacity: usize,
overflow: O,
g: G
) -> RoutineStreamRing<T, E>
where
G: Generator<Yield = Option<T>, Return = Result<Option<T>, E>>,
O: Fn(T) -> Result<(), E>,
G: Send + 'static,
T: Send + 'static,
E: Send + 'static,
O: Send + 'static, { ... } fn stream_ring_skip<G, T, E>(
&self,
capacity: usize,
g: G
) -> RoutineStreamRing<T, E>
where
G: Generator<Yield = Option<T>, Return = Result<Option<T>, E>>,
G: Send + 'static,
T: Send + 'static,
E: Send + 'static, { ... } fn stream_ring_overwrite<G, T, E>(
&self,
capacity: usize,
g: G
) -> RoutineStreamRing<T, E>
where
G: Generator<Yield = Option<T>, Return = Result<Option<T>, E>>,
G: Send + 'static,
T: Send + 'static,
E: Send + 'static, { ... } }
A thread interface.
Required Methods
fn all() -> *mut [Self]
Returns a mutable pointer to the static array of threads.
fn routines(&self) -> &RoutineStack
Returns a reference to the routines stack.
fn routines_mut(&mut self) -> &mut RoutineStack
Returns a mutable reference to the routines stack.
fn task(&self) -> &TaskCell
Returns the cell for the task pointer.
fn preempted(&mut self) -> &mut usize
Returns a mutable reference to the stored index of the preempted thread.
Provided Methods
fn routine<G>(&self, g: G) where
G: Generator<Yield = (), Return = ()>,
G: Send + 'static,
G: Generator<Yield = (), Return = ()>,
G: Send + 'static,
Adds a new routine to the stack. This method accepts a generator.
fn routine_fn<F>(&self, f: F) where
F: FnOnce(),
F: Send + 'static,
F: FnOnce(),
F: Send + 'static,
Adds a new routine to the stack. This method accepts a closure.
fn future<G, T, E>(&self, g: G) -> RoutineFuture<T, E> where
G: Generator<Yield = (), Return = Result<T, E>>,
G: Send + 'static,
T: Send + 'static,
E: Send + 'static,
G: Generator<Yield = (), Return = Result<T, E>>,
G: Send + 'static,
T: Send + 'static,
E: Send + 'static,
Adds a new routine to the stack. Returns a Future
of the routine's
return value. This method accepts a generator.
fn future_fn<F, T, E>(&self, f: F) -> RoutineFuture<T, E> where
F: FnOnce() -> Result<T, E>,
F: Send + 'static,
T: Send + 'static,
E: Send + 'static,
F: FnOnce() -> Result<T, E>,
F: Send + 'static,
T: Send + 'static,
E: Send + 'static,
Adds a new routine to the stack. Returns a Future
of the routine's
return value. This method accepts a closure.
fn stream<G, E, O>(&self, overflow: O, g: G) -> RoutineStreamUnit<E> where
G: Generator<Yield = Option<()>, Return = Result<Option<()>, E>>,
O: Fn() -> Result<(), E>,
G: Send + 'static,
E: Send + 'static,
O: Send + 'static,
G: Generator<Yield = Option<()>, Return = Result<Option<()>, E>>,
O: Fn() -> Result<(), E>,
G: Send + 'static,
E: Send + 'static,
O: Send + 'static,
Adds a new routine to the stack. Returns a Stream
of routine's yielded
values. If overflow
returns Ok(())
, current value will be skipped.
This method only accepts ()
as values.
fn stream_skip<G, E>(&self, g: G) -> RoutineStreamUnit<E> where
G: Generator<Yield = Option<()>, Return = Result<Option<()>, E>>,
G: Send + 'static,
E: Send + 'static,
G: Generator<Yield = Option<()>, Return = Result<Option<()>, E>>,
G: Send + 'static,
E: Send + 'static,
Adds a new routine to the stack. Returns a Stream
of routine's yielded
values. Values will be skipped on overflow. This method only accepts ()
as values.
fn stream_ring<G, T, E, O>(
&self,
capacity: usize,
overflow: O,
g: G
) -> RoutineStreamRing<T, E> where
G: Generator<Yield = Option<T>, Return = Result<Option<T>, E>>,
O: Fn(T) -> Result<(), E>,
G: Send + 'static,
T: Send + 'static,
E: Send + 'static,
O: Send + 'static,
&self,
capacity: usize,
overflow: O,
g: G
) -> RoutineStreamRing<T, E> where
G: Generator<Yield = Option<T>, Return = Result<Option<T>, E>>,
O: Fn(T) -> Result<(), E>,
G: Send + 'static,
T: Send + 'static,
E: Send + 'static,
O: Send + 'static,
Adds a new routine to the stack. Returns a Stream
of routine's yielded
values. If overflow
returns Ok(())
, currenct value will be skipped.
fn stream_ring_skip<G, T, E>(
&self,
capacity: usize,
g: G
) -> RoutineStreamRing<T, E> where
G: Generator<Yield = Option<T>, Return = Result<Option<T>, E>>,
G: Send + 'static,
T: Send + 'static,
E: Send + 'static,
&self,
capacity: usize,
g: G
) -> RoutineStreamRing<T, E> where
G: Generator<Yield = Option<T>, Return = Result<Option<T>, E>>,
G: Send + 'static,
T: Send + 'static,
E: Send + 'static,
Adds a new routine to the stack. Returns a Stream
of routine's yielded
values. New values will be skipped on overflow.
fn stream_ring_overwrite<G, T, E>(
&self,
capacity: usize,
g: G
) -> RoutineStreamRing<T, E> where
G: Generator<Yield = Option<T>, Return = Result<Option<T>, E>>,
G: Send + 'static,
T: Send + 'static,
E: Send + 'static,
&self,
capacity: usize,
g: G
) -> RoutineStreamRing<T, E> where
G: Generator<Yield = Option<T>, Return = Result<Option<T>, E>>,
G: Send + 'static,
T: Send + 'static,
E: Send + 'static,
Adds a new routine to the stack. Returns a Stream
of routine's yielded
values. Old values will be overwritten on overflow.