A class supporting the implementation of handles with a 32-bit integer value.
More...
#include "nn/nlib/HandleMaker.h"
template<class HBODY>
class nn::nlib::HandleMaker< HBODY >
A class supporting the implementation of handles with a 32-bit integer value.
- Template Parameters
-
HBODY | Handle instance type. |
- Description
- A class providing a mechanism to associate a 32-bit integer value (a handle) with an object (a handle instance). Using
HandleMaker
enables you to easily provide handles with the following features:
- Access to the handle instance through the handle is thread safe.
- Even if you use the handle after closing it (i.e. the handle is no longer valid), an error (generally,
EBADF
) can be returned without causing a crash.
- The above features apply also for cases where the handle is closed from a different thread.
- Since an integer value that acts as a handle will not be reused immediately, you can avoid unintentional access to the handle instance.
- -1, 0, 1, 2, or 3 will not be assigned as a handle value.
- Examples:
- misc/handlemaker/handlemaker.cpp.
Definition at line 93 of file HandleMaker.h.
◆ AttachHandleBody()
Gets a handle that should be associated with the handle instance.
- Parameters
-
[out] | handle | Pointer to the handle associated with body. |
[in] | body | Handle instance to be associated with the handle. |
- Return values
-
0 | Success. |
ENFILE | No handle is available that can be assigned. |
Definition at line 195 of file HandleMaker.h.
◆ GetHandleAccess()
Obtains access from a handle to the handle instance.
- Parameters
-
[in] | handle | Handle obtained with AttachHandleBody() . |
[out] | access | Accessor to an instance corresponding to the handle. |
- Return values
-
0 | Success. |
EBADF | The handle is not valid. |
Definition at line 262 of file HandleMaker.h.
The documentation for this class was generated from the following files: