[][src]Struct lightproc::proc_stack::ProcStack

pub struct ProcStack {
    pub pid: AtomicUsize,
    // some fields omitted
}

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.

Methods

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]

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]

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]

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]

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]

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]

impl Debug for ProcStack[src]

impl Default for ProcStack[src]

Default implementation for the ProcStack

Auto Trait Implementations

Blanket Implementations

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

impl<T> AsAny for T where
    T: Any
[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> State for T where
    T: Send + Sync + 'static, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.