Struct lunatic::ThisModule [−][src]
pub struct ThisModule { /* fields omitted */ }
Expand description
A pointer to the current module.
This type is useful because it allows us to spawn existing functions by reference into a new environment. This is only possible if we are running inside the module we are spawning the processes from, otherwise we could not reference them by table id.
Implementations
pub fn spawn<T: Serialize + DeserializeOwned>(
&self,
function: fn(_: Mailbox<T>)
) -> Result<Process<T>, LunaticError>
pub fn spawn<T: Serialize + DeserializeOwned>(
&self,
function: fn(_: Mailbox<T>)
) -> Result<Process<T>, LunaticError>
Spawns a new process from a function.
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.
pub fn spawn_link<T, P, M>(
&self,
mailbox: M,
function: fn(_: Mailbox<T>)
) -> Result<(Process<T>, Tag, LinkMailbox<P>), LunaticError> where
T: Serialize + DeserializeOwned,
P: Serialize + DeserializeOwned,
M: TransformMailbox<P>,
pub fn spawn_link<T, P, M>(
&self,
mailbox: M,
function: fn(_: Mailbox<T>)
) -> Result<(Process<T>, Tag, LinkMailbox<P>), LunaticError> where
T: Serialize + DeserializeOwned,
P: Serialize + DeserializeOwned,
M: TransformMailbox<P>,
Spawns a new process from a function and links it to the parent.
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.
pub fn spawn_link_unwrap<T, P, M>(
&self,
mailbox: M,
function: fn(_: Mailbox<T>)
) -> Result<(Process<T>, Mailbox<P>), LunaticError> where
T: Serialize + DeserializeOwned,
P: Serialize + DeserializeOwned,
M: TransformMailbox<P>,
pub fn spawn_link_unwrap<T, P, M>(
&self,
mailbox: M,
function: fn(_: Mailbox<T>)
) -> Result<(Process<T>, Mailbox<P>), LunaticError> where
T: Serialize + DeserializeOwned,
P: Serialize + DeserializeOwned,
M: TransformMailbox<P>,
Spawns a new process from a function and links it to the parent.
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.
If the linked process dies, the parent is going to die too.
pub fn spawn_with<C: Serialize + DeserializeOwned, T: Serialize + DeserializeOwned>(
&self,
context: C,
function: fn(_: C, _: Mailbox<T>)
) -> Result<Process<T>, LunaticError>
pub fn spawn_with<C: Serialize + DeserializeOwned, T: Serialize + DeserializeOwned>(
&self,
context: C,
function: fn(_: C, _: Mailbox<T>)
) -> Result<Process<T>, LunaticError>
Spawns a new process from a function and context.
-
context
is data that we want to pass to the newly spawned process. It needs to impl. the [Serialize + DeserializeOwned
] trait. -
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. The first argument of this function is going to be the receivedcontext
.
pub fn spawn_link_with<C, T, P, M>(
&self,
mailbox: M,
context: C,
function: fn(_: C, _: Mailbox<T>)
) -> Result<(Process<T>, Tag, LinkMailbox<P>), LunaticError> where
C: Serialize + DeserializeOwned,
T: Serialize + DeserializeOwned,
P: Serialize + DeserializeOwned,
M: TransformMailbox<P>,
pub fn spawn_link_with<C, T, P, M>(
&self,
mailbox: M,
context: C,
function: fn(_: C, _: Mailbox<T>)
) -> Result<(Process<T>, Tag, LinkMailbox<P>), LunaticError> where
C: Serialize + DeserializeOwned,
T: Serialize + DeserializeOwned,
P: Serialize + DeserializeOwned,
M: TransformMailbox<P>,
Spawns a new process from a function and context, and links it to the parent.
-
context
is data that we want to pass to the newly spawned process. It needs to impl. the [Serialize + DeserializeOwned
] trait. -
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. The first argument of this function is going to be the receivedcontext
.
pub fn spawn_link_unwrap_with<C, T, P, M>(
&self,
mailbox: M,
context: C,
function: fn(_: C, _: Mailbox<T>)
) -> Result<(Process<T>, Mailbox<P>), LunaticError> where
C: Serialize + DeserializeOwned,
T: Serialize + DeserializeOwned,
P: Serialize + DeserializeOwned,
M: TransformMailbox<P>,
pub fn spawn_link_unwrap_with<C, T, P, M>(
&self,
mailbox: M,
context: C,
function: fn(_: C, _: Mailbox<T>)
) -> Result<(Process<T>, Mailbox<P>), LunaticError> where
C: Serialize + DeserializeOwned,
T: Serialize + DeserializeOwned,
P: Serialize + DeserializeOwned,
M: TransformMailbox<P>,
Spawns a new process from a function and context, and links it to the parent.
-
context
is data that we want to pass to the newly spawned process. It needs to impl. the [Serialize + DeserializeOwned
] trait. -
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. The first argument of this function is going to be the receivedcontext
.
If the linked process dies, the parent is going to die too.