Struct bastion::executor::ProcStack [−][src]
pub struct ProcStack {
pub pid: AtomicUsize,
// some fields omitted
}
Expand description
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
Adds pid for the process which is going to take this stack
Example
use lightproc::proc_stack::ProcStack;
ProcStack::default()
.with_pid(1);
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 });
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"); });
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"); });
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"); });
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);
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
Auto Trait Implementations
impl !RefUnwindSafe for ProcStack
impl !UnwindSafe for ProcStack
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more