|
asynchrony 2.3.1
Add asynchrony to your C++ applications using standard C++20
|
Public Member Functions | |
| resource_wrap ()=delete | |
| Default constructor is deleted Resources must be explicitly constructed with a valid resource. | |
| resource_wrap (T &&src, std::function< void(T &&)> &&f={}) | |
| Construct a resource_wrap with a resource and optional callback. | |
| resource_wrap (const T &)=delete | |
| Copy constructor is deleted Resources are move-only to maintain clear ownership semantics. | |
| resource_wrap & | operator= (T &&src) |
| Move assignment operator. | |
| resource_wrap & | operator= (const resource_wrap &)=delete |
| Copy assignment is deleted. | |
| auto | operator* () -> T & |
| operator T () | |
| Type conversion operator. | |
| ~resource_wrap () | |
| Destructor - automatically returns resource to pool if valid. | |
Protected Attributes | |
| T | rsrc {} |
| The actual resource being wrapped. | |
| uint64_t | debugId {static_cast<uint64_t>(std::rand())} |
| Debug identifier for tracking (used in DEBUG builds). | |
| std::function< void(T &&)> | putbackCallback {} |
| Callback function to return the resource to the pool Called by destructor when resource is valid. | |
| bool | isValid {false} |
| Tracks whether the resource is valid and should be returned to pool Prevents returning uninitialized or moved-out resources. | |
Definition at line 105 of file resource_pool.hpp.
|
inline |
Construct a resource_wrap with a resource and optional callback.
| src | R-value reference to the resource to wrap |
| f | Optional callback function to return resource to pool |
The resource is marked as valid upon construction. The callback is typically provided by resource_pool::checkout() to automatically return the resource.
Definition at line 141 of file resource_pool.hpp.
|
inline |
Destructor - automatically returns resource to pool if valid.
The destructor implements the RAII pattern:
This ensures resources are always properly managed, even if an exception occurs.
Definition at line 222 of file resource_pool.hpp.
|
inline |
Type conversion operator.
Allows implicit conversion to the resource type. Useful for passing to functions expecting the resource type.
Definition at line 208 of file resource_pool.hpp.
|
inline |
Definition at line 197 of file resource_pool.hpp.
|
inline |
Move assignment operator.
| src | R-value reference to the resource to assign |
Assigns a new resource to this wrapper and marks it as valid. The previous resource (if any) is discarded.
Definition at line 173 of file resource_pool.hpp.
|
protected |
Debug identifier for tracking (used in DEBUG builds).
Definition at line 112 of file resource_pool.hpp.
|
protected |
Tracks whether the resource is valid and should be returned to pool Prevents returning uninitialized or moved-out resources.
Definition at line 122 of file resource_pool.hpp.
|
protected |
Callback function to return the resource to the pool Called by destructor when resource is valid.
Definition at line 116 of file resource_pool.hpp.
|
protected |
The actual resource being wrapped.
Definition at line 109 of file resource_pool.hpp.