Home | Libraries | People | FAQ | More |
boost::process::handle
// In header: <boost/process/handle.hpp> class handle { public: // types typedef NativeSystemHandle native_type; // member classes/structs/unions class impl { public: // types typedef handle::native_type native_type; // construct/copy/destruct impl(native_type, close_type); ~impl(); // public member functions bool valid() const; void close() ; native_type native() const; native_type release() ; }; enum close_type; // construct/copy/destruct handle(); handle(native_type, close_type = handle::do_close); // public member functions bool valid() const; void close() ; native_type native() const; native_type release() ; // private static functions static const native_type invalid_handle() ; };
RAII model for handles.
The handle class is a RAII model for native handles. This class wraps one of such handles grabbing its ownership, and automaticaly closes it upon destruction. It is used to avoid leaking open handles, shall an unexpected execution trace occur.
handle
public
construct/copy/destructhandle();
Constructs an invalid handle.
valid()
handle(native_type native, close_type close = handle::do_close);
Constructs a handle from a native handle.
This constructor creates a new handle object that takes ownership of the given native handle. If close is set to handle::dont_close the native handle is not closed upon destruction. The user must not close native if it is owned by a handle object. Ownership can be reclaimed using release().
release()
handle
public member functionsbool valid() const;
Checks whether the handle is valid or not.
Returns: |
true if the handle is valid; false otherwise. |
void close() ;
Closes the handle.
Postconditions: |
The handle is invalid. The native handle is closed. |
native_type native() const;
Gets the native handle.
The caller can issue any operation on it except closing it. If closing is required, release() shall be used.
Returns: |
The native handle. |
native_type release() ;
Reclaims ownership of the native handle.
The caller is responsible of closing the native handle.
Postconditions: |
The handle is invalid. |
Returns: |
The native handle. |
handle
private static functionsstatic const native_type invalid_handle() ;
Constant function representing an invalid handle value.
Returns the platform-specific handle value that represents an invalid handle. This is a constant function rather than a regular constant because, in the latter case, we cannot define it under Windows due to the value being of a complex type.