SPH
|
Holds a handle to a created process. More...
#include <Process.h>
Public Member Functions | |
Process ()=default | |
Creates a null process handle. More... | |
Process (const Path &path, Array< std::string > &&args) | |
Creates a process by running given executable file. More... | |
void | wait () |
Blocks the calling thread until the managed process exits. The function may block indefinitely. More... | |
void | waitFor (const uint64_t duration) |
Blocks the calling thread until the managed process exits or for specified duration. More... | |
void | waitUntil (const Function< bool()> &condition, const uint64_t checkEvery=100) |
Blocks the calling thread until the managed process exits or until given condition is met. More... | |
Holds a handle to a created process.
The class allows to start, manage and kill a process. Note that the calling thread does not wait until the created process exits, unless function wait (waitFor, waitUntil) is executed. In particular, the process is not blocked in the destructor.
|
default |
Creates a null process handle.
Creates a process by running given executable file.
path | Path to the executable. The file must exist. |
args | Arguments passes to the executable. Can be an empty array. |
Exception | if the file does not exist or the process fails to start. |
Definition at line 21 of file Process.cpp.
void Process::wait | ( | ) |
Blocks the calling thread until the managed process exits. The function may block indefinitely.
Definition at line 50 of file Process.cpp.
void Process::waitFor | ( | const uint64_t | duration | ) |
Blocks the calling thread until the managed process exits or for specified duration.
duration | Maximum wait duration in milliseconds. |
void Process::waitUntil | ( | const Function< bool()> & | condition, |
const uint64_t | checkEvery = 100 |
||
) |
Blocks the calling thread until the managed process exits or until given condition is met.
condition | Function returning true if the wait should be interrupted. |
checkEvery | Period of condition checking in milliseconds |