Skip to main content

WorkerHandle

Trait WorkerHandle 

Source
pub trait WorkerHandle: Send + 'static {
    // Required methods
    fn pid(&self) -> u32;
    fn send_task<'life0, 'async_trait>(
        &'life0 mut self,
        msg: RpcMessage,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn recv_task<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<Option<RpcMessage>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn send_control<'life0, 'async_trait>(
        &'life0 mut self,
        msg: RpcMessage,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn recv_control<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<Option<RpcMessage>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn terminate<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

A handle to a spawned worker.

The pool sends task-channel frames via send_task and receives them via recv_task. Control-channel frames travel through send_control and recv_control. Termination is via terminate.

Required Methods§

Source

fn pid(&self) -> u32

Worker process ID (informational; used for logging).

Source

fn send_task<'life0, 'async_trait>( &'life0 mut self, msg: RpcMessage, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Send a frame on the task channel.

Source

fn recv_task<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<Option<RpcMessage>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Receive a frame from the task channel. Returns None on EOF.

Source

fn send_control<'life0, 'async_trait>( &'life0 mut self, msg: RpcMessage, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Send a frame on the control channel.

Source

fn recv_control<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<Option<RpcMessage>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Receive a frame from the control channel. Returns None on EOF.

Source

fn terminate<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Request the worker to terminate. Implementations send SIGTERM, then after a grace period SIGKILL, then waitpid.

Implementors§