ScopedProcessHandle#

Fully qualified name: carb::launcher::ScopedProcessHandle

Defined in carb/launcher/LauncherUtils.h

class ScopedProcessHandle : public std::unique_ptr<Process, detail::ProcessHandleDeleter>#

A scoped handle to a process handle object that automatically destroys the process handle when it goes out of scope.

This class inherits from std::unique_ptr with a custom deleter to handle process cleanup.

Note

Once a process handle is assigned to this object, it is fully owned and managed by this object. It may still be accessed directly using the get() method or cast operator, but must not be destroyed directly otherwise the behavior is undefined. The contained handle can be released from this object using the release() method, but it is then the caller’s responsibility to destroy the handle when it is no longer needed.

Public Types

using Base = std::unique_ptr<Process, detail::ProcessHandleDeleter>#

Base type alias for the parent unique_ptr class.

Public Functions

ScopedProcessHandle() = default#

Default constructor creates an empty handle.

inline ScopedProcessHandle(Process *proc) noexcept#

Constructor that takes ownership of a process handle.

Parameters:

proc[in] The process handle to take ownership of. May be nullptr.

inline operator Process*() const noexcept#

Implicit conversion operator to get the raw process handle.

Returns:

The underlying process handle pointer, which may be nullptr.

inline ScopedProcessHandle &operator=(Process *proc) noexcept#

Assignment operator to take ownership of a new process handle.

Parameters:

proc[in] The process handle to take ownership of. May be nullptr. If this object already owns a handle, it will be destroyed before the new handle is assigned.

Returns:

Reference to this object.