[−][src]Struct lightproc::proc_stack::ProcStack
Stack abstraction for lightweight processes
Example
use lightproc::proc_stack::ProcStack; use lightproc::proc_state::EmptyProcState; ProcStack::default() .with_before_start(|s: &mut EmptyProcState| { println!("Before start"); }) .with_after_complete(|s: &mut EmptyProcState| { println!("After complete"); }) .with_after_panic(|s: &mut EmptyProcState| { println!("After panic"); });
Fields
pid: AtomicUsize
Process ID for the Lightweight Process
Can be used to identify specific processes during any executor, reactor implementations.
Implementations
impl ProcStack
[src]
pub fn with_pid(self, pid: usize) -> Self
[src]
Adds pid for the process which is going to take this stack
Example
use lightproc::proc_stack::ProcStack; ProcStack::default() .with_pid(1);
pub fn with_state<S>(self, state: S) -> Self where
S: State + 'static,
[src]
S: State + 'static,
Adds state for the process which is going to be embedded into this stack.
Example
use lightproc::proc_stack::ProcStack; pub struct GlobalState { pub amount: usize } ProcStack::default() .with_pid(1) .with_state(GlobalState { amount: 1 });
pub fn with_before_start<C, S>(self, callback: C) -> Self where
S: State,
C: Fn(&mut S) + Send + Sync + 'static,
[src]
S: State,
C: Fn(&mut S) + Send + Sync + 'static,
Adds a callback that will be executed before polling inner future to the stack
use lightproc::proc_stack::{ProcStack}; use lightproc::proc_state::EmptyProcState; ProcStack::default() .with_before_start(|s: &mut EmptyProcState| { println!("Before start"); });
pub fn with_after_complete<C, S>(self, callback: C) -> Self where
S: State,
C: Fn(&mut S) + Send + Sync + 'static,
[src]
S: State,
C: Fn(&mut S) + Send + Sync + 'static,
Adds a callback that will be executed after inner future resolves to an output to the stack
use lightproc::proc_stack::ProcStack; use lightproc::proc_state::EmptyProcState; ProcStack::default() .with_after_complete(|s: &mut EmptyProcState| { println!("After complete"); });
pub fn with_after_panic<C, S>(self, callback: C) -> Self where
S: State,
C: Fn(&mut S) + Send + Sync + 'static,
[src]
S: State,
C: Fn(&mut S) + Send + Sync + 'static,
Adds a callback that will be executed after inner future panics to the stack
use lightproc::proc_stack::ProcStack; use lightproc::proc_state::EmptyProcState; ProcStack::default() .with_after_panic(|s: &mut EmptyProcState| { println!("After panic"); });
pub fn get_pid(&self) -> usize
[src]
Utility function to get_pid for the implementation of executors.
use lightproc::proc_stack::ProcStack; let proc = ProcStack::default().with_pid(123); assert_eq!(proc.get_pid(), 123);
pub fn get_state<S>(&self) -> S where
S: State + Copy + 'static,
[src]
S: State + Copy + 'static,
Get the state which is embedded into this ProcStack.
use lightproc::proc_stack::ProcStack; #[derive(Copy, Clone)] pub struct GlobalState { pub amount: usize } let mut proc = ProcStack::default().with_pid(123) .with_state(GlobalState { amount: 0} ); let state = proc.get_state::<GlobalState>();
Trait Implementations
impl Clone for ProcStack
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for ProcStack
[src]
impl Default for ProcStack
[src]
Default implementation for the ProcStack
Auto Trait Implementations
impl !RefUnwindSafe for ProcStack
impl Send for ProcStack
impl Sync for ProcStack
impl Unpin for ProcStack
impl !UnwindSafe for ProcStack
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> AsAny for T where
T: Any,
[src]
T: Any,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> State for T where
T: Send + Sync + 'static,
[src]
T: Send + Sync + 'static,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,