Struct lunatic::process::Process[][src]

pub struct Process { /* fields omitted */ }

A Process consists of its own stack and heap. It can only share data with other processes through message passing.

Dropping a Process cancels it. To drop the Task handle without canceling it, use detach() instead.


impl Process[src]

pub fn spawn_with<T>(context: T, function: fn(_: T)) -> Process where
    T: Serialize + DeserializeOwned

Spawns a new process from a function and context.

  • function is the starting point of the new process. The new process doesn't share memory with its parent, because of this the function can't capture anything from parents.

  • context is data that we want to pass to the newly spawned process. It needs to be serializable.

Safety: Rust doesn't have a concept of "separate" memories and you will still be able to reference global static variables, but IT'S NOT SAFE to do so.

pub fn detach(self)[src]

Detaches the Process to let it keep running in the background.

pub fn join(self) -> Result<(), ()>[src]

Waits on a Process to finish.

Returns an error if the process failed.

pub fn sleep(milliseconds: u64)[src]

Suspends the current process for milliseconds.

Trait Implementations

impl Drop for Process[src]

Auto Trait Implementations

Blanket Implementations

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

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.