...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::process::v1::group
// In header: <boost/process/v1/group.hpp> class group { public: // types typedef unspecified group_handle; typedef group_handle::handle_t native_handle_t; // Native representation of the handle. // public member functions explicit group(group_handle &&); explicit group(native_handle_t &); group(const group &) = delete; group(group &&); group() = default; group & operator=(const group &) = delete; group & operator=(group &&); void detach(); void join(); bool joinable(); ~group(); native_handle_t native_handle() const; void wait(); void wait(std::error_code &) noexcept; template<typename Rep, typename Period> bool wait_for(const std::chrono::duration< Rep, Period > &); template<typename Rep, typename Period> bool wait_for(const std::chrono::duration< Rep, Period > &, std::error_code &) noexcept; template<typename Clock, typename Duration> bool wait_until(const std::chrono::time_point< Clock, Duration > &); template<typename Clock, typename Duration> bool wait_until(const std::chrono::time_point< Clock, Duration > &, std::error_code &) noexcept; bool valid() const; explicit operator bool() const; void terminate(); void terminate(std::error_code &) noexcept; void add(const child &); void add(const child &, std::error_code &) noexcept; bool has(const child &); bool has(const child &, std::error_code &) noexcept; };
Represents a process group.
Groups are movable but non-copyable. The destructor automatically closes handles to the group process.
The group will have the same interface as std::thread.
![]() |
Note |
---|---|
If the destructor is called without a previous detach or wait, the group will be terminated. |
![]() |
Important |
---|---|
If a default-constructed group is used before being used in a process launch, the behaviour is undefined. |
![]() |
Important |
---|---|
Waiting for groups is currently broken on windows and will most likely result in a dead-lock. |
group
public member functionsexplicit group(group_handle && ch);
explicit group(native_handle_t & handle);Construct the group from a native_handle.
group(const group &) = delete;
group(group && lhs);Move constructor.
group() = default;Default constructor.
group & operator=(const group &) = delete;
group & operator=(group && lhs);Move assign.
void detach();Detach the group.
void join();
Join the child. This just calls wait, but that way the naming is similar to std::thread
bool joinable();
Check if the child is joinable.
~group();
Destructor
![]() |
Note |
---|---|
If the destructor is called without a previous detach or wait, the group will be terminated. |
native_handle_t native_handle() const;Obtain the native handle of the group.
void wait();Wait for the process group to exit.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void wait(std::error_code & ec) noexcept;
template<typename Rep, typename Period> bool wait_for(const std::chrono::duration< Rep, Period > & rel_time);
Wait for the process group to exit for period of time. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Returns: |
True if all child processes exited while waiting. |
template<typename Rep, typename Period> bool wait_for(const std::chrono::duration< Rep, Period > & rel_time, std::error_code & ec) noexcept;
template<typename Clock, typename Duration> bool wait_until(const std::chrono::time_point< Clock, Duration > & timeout_time);
Wait for the process group to exit until a point in time. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Returns: |
True if all child processes exited while waiting. |
template<typename Clock, typename Duration> bool wait_until(const std::chrono::time_point< Clock, Duration > & timeout_time, std::error_code & ec) noexcept;
bool valid() const;Check if the group has a valid handle.
explicit operator bool() const;Convenience to call valid.
void terminate();Terminate the process group, i.e. all processes in the group.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void terminate(std::error_code & ec) noexcept;
void add(const child & c);Assign a child process to the group.
void add(const child & c, std::error_code & ec) noexcept;
bool has(const child & c);Check if the child process is in the group.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool has(const child & c, std::error_code & ec) noexcept;