Skip to main content

Worker

Trait Worker 

Source
pub trait Worker: Send {
    // Required methods
    fn start(&mut self) -> Result<()>;
    fn abort(&mut self, kill: bool);
    fn state(&self) -> WorkerState;
    fn set_handler(&mut self, handler: Box<dyn EventHandler>);
    fn read_fds(&self) -> Vec<RawFd> ;
    fn write_fds(&self) -> Vec<RawFd> ;
    fn handle_read(&mut self, fd: RawFd) -> Result<()>;
    fn handle_write(&mut self, fd: RawFd) -> Result<()>;
    fn is_done(&self) -> bool;
    fn retcodes(&self) -> &HashMap<String, i32>;
    fn num_nodes(&self) -> usize;
    fn take_handler(&mut self) -> Option<Box<dyn EventHandler>>;
}
Expand description

Trait for worker implementations.

A worker executes commands across multiple nodes, handling I/O events and managing child processes.

Required Methods§

Source

fn start(&mut self) -> Result<()>

Start the worker.

Source

fn abort(&mut self, kill: bool)

Abort the worker, optionally killing child processes.

Source

fn state(&self) -> WorkerState

Get the worker’s current state.

Source

fn set_handler(&mut self, handler: Box<dyn EventHandler>)

Set the event handler for this worker.

Source

fn read_fds(&self) -> Vec<RawFd>

Get file descriptors for read interest.

Source

fn write_fds(&self) -> Vec<RawFd>

Get file descriptors for write interest.

Source

fn handle_read(&mut self, fd: RawFd) -> Result<()>

Handle a read event on the given file descriptor.

Source

fn handle_write(&mut self, fd: RawFd) -> Result<()>

Handle a write event on the given file descriptor.

Source

fn is_done(&self) -> bool

Check if the worker has completed.

Source

fn retcodes(&self) -> &HashMap<String, i32>

Get the return codes map: node -> return_code.

Source

fn num_nodes(&self) -> usize

Get the number of nodes.

Source

fn take_handler(&mut self) -> Option<Box<dyn EventHandler>>

Take the event handler out of the worker (used by Task to extract gathered data).

Implementors§