pub struct ProcessManager { /* private fields */ }
Expand description
ProcessManager
provides asynchronous API for spawning and managing multiple processes.
The implementation relies on the Actor model
architecture which benefits from high concurrency and scalability and loose-coupling between actors (units doing some work).
ProcessManager
is a main actor responsible for:
- spawning new actors (eg. for sending/reading messages to/from user-defined processes),
- forwarding messages between client and other actors.
All files needed to handle spawned processes are kept in user-specified directory, called further working directory
.
Each process has own, unique subdirectory (process directory
) inside working directory
,
where ProcessManager
creates files/named pipes used for communication, logging etc.
If the process has been killed manually, then its process directory
is removed immediately.
Each spawned process has its own ProcessId
, which can be used to interact with it through ProcessManagerHandle
.
For convenience of interacting with one process, use a ProcessHandle
wrapper.
Please note that once all manager handles are dropped, then all child processes will be killed and all process directories
will be deleted.
Implementations§
Source§impl ProcessManager
impl ProcessManager
Sourcepub fn spawn(working_directory: PathBuf) -> Result<ProcessManagerHandle, Error>
pub fn spawn(working_directory: PathBuf) -> Result<ProcessManagerHandle, Error>
Spawns a new process manager task with a given working_directory
, returning a handle associated with the manager’s task.
The Err
value is returned, if provided working_directory
is not a directory or is not writeable.
§Examples
let working_directory = PathBuf::from("/some/temp/path");
let handle = ProcessManager::spawn(working_directory).expect("Invalid working directory");