Struct lunatic_twitchax_patch::ap::ProcessRef
source · pub struct ProcessRef<T>where
T: AbstractProcess,{ /* private fields */ }Expand description
A reference to a running AbstractProcess.
ProcessRef<T> is different from a Process in the ability to handle
messages of different types, as long as the traits
MessageHandler<Message>, RequestHandler<Request> or
DeferredRequestHandler<Request> are implemented for T.
Implementations§
source§impl<T> ProcessRef<T>where
T: AbstractProcess,
impl<T> ProcessRef<T>where
T: AbstractProcess,
sourcepub fn lookup<N: ProcessName + ?Sized>(name: &N) -> Option<Self>
pub fn lookup<N: ProcessName + ?Sized>(name: &N) -> Option<Self>
Returns a process registered under name if it exists and the signature
matches.
sourcepub fn register<N: ProcessName>(&self, name: &N)
pub fn register<N: ProcessName>(&self, name: &N)
Registers process under name.
sourcepub fn is_alive(&self) -> bool
pub fn is_alive(&self) -> bool
Returns true for processes on the local node that are running.
Panics if called on a remote process.
sourcepub fn shutdown(&self)
pub fn shutdown(&self)
Shuts the AbstractProcess down.
sourcepub fn shutdown_timeout(&self, timeout: Option<Duration>) -> Result<(), Timeout>
pub fn shutdown_timeout(&self, timeout: Option<Duration>) -> Result<(), Timeout>
Shuts the AbstractProcess down.
If a timeout is specified the function will only block for the timeout
period before returning Err(Timeout).
sourcepub fn send<M: 'static>(&self, message: M)where
T::Serializer: CanSerialize<M>,
pub fn send<M: 'static>(&self, message: M)where
T::Serializer: CanSerialize<M>,
Send message to the process.
sourcepub fn request<R: 'static>(&self, request: R) -> T::Responsewhere
T: RequestHandler<R>,
T::Serializer: CanSerialize<R> + CanSerialize<T::Response> + CanSerialize<RequestMessage<R, T::Response, T::Serializer>>,
pub fn request<R: 'static>(&self, request: R) -> T::Responsewhere
T: RequestHandler<R>,
T::Serializer: CanSerialize<R> + CanSerialize<T::Response> + CanSerialize<RequestMessage<R, T::Response, T::Serializer>>,
Make a request to the process.
sourcepub fn deferred_request<R: 'static>(&self, request: R) -> T::Responsewhere
T: DeferredRequestHandler<R>,
T::Serializer: CanSerialize<R> + CanSerialize<T::Response> + CanSerialize<RequestMessage<R, T::Response, T::Serializer>>,
pub fn deferred_request<R: 'static>(&self, request: R) -> T::Responsewhere
T: DeferredRequestHandler<R>,
T::Serializer: CanSerialize<R> + CanSerialize<T::Response> + CanSerialize<RequestMessage<R, T::Response, T::Serializer>>,
Make a deferred request to the process.
sourcepub fn with_timeout(self, timeout: Duration) -> WithTimeout<ProcessRef<T>>
pub fn with_timeout(self, timeout: Duration) -> WithTimeout<ProcessRef<T>>
Set a timeout on the next action performed on this process.
Timeouts affect ProcessRef::shutdown, ProcessRef::request and
ProcessRef::deferred_request functions.
sourcepub fn with_delay(self, timeout: Duration) -> WithDelay<ProcessRef<T>>
pub fn with_delay(self, timeout: Duration) -> WithDelay<ProcessRef<T>>
Set a delay on the next ProcessRef::send performed on this process.
This is a non-blocking function, meaning that send is going to be
performed in the background while the execution continues. The send
call will return a reference to the timer allowing you to cancel it.
source§impl<T> ProcessRef<T>
impl<T> ProcessRef<T>
sourcepub fn wait_on_shutdown(&self)
pub fn wait_on_shutdown(&self)
Blocks until the Supervisor shuts down.
This function will not request a shutdown, just wait until someone else shuts the supervisor down.
A tagged message will be sent to the supervisor process as a request and the subscription will be registered. When the supervisor process shuts down, the subscribers will be each notified by a response message and therefore be unblocked after having received the awaited message.