27 #ifndef _UCOMMON_REUSE_H_ 28 #define _UCOMMON_REUSE_H_ 30 #ifndef _UCOMMON_THREAD_H_ 36 typedef unsigned short vectorsize_t;
45 class __EXPORT ArrayReuse :
public ReusableAllocator
49 unsigned count,
limit, used;
52 __DELETE_DEFAULTS(ArrayReuse);
55 ArrayReuse(
size_t objsize,
unsigned c);
56 ArrayReuse(
size_t objsize,
unsigned c,
void *memory);
65 bool avail(
void)
const;
67 ReusableObject *
get(timeout_t timeout);
68 ReusableObject *
get(void);
69 ReusableObject *request(
void);
79 class __EXPORT PagerReuse :
protected __PROTOCOL MemoryRedirect,
protected ReusableAllocator
82 unsigned limit, count;
85 __DELETE_DEFAULTS(PagerReuse);
88 PagerReuse(mempager *pager,
size_t objsize,
unsigned count);
91 bool avail(
void)
const;
92 ReusableObject *
get(void);
93 ReusableObject *
get(timeout_t timeout);
94 ReusableObject *request(
void);
115 ArrayReuse(sizeof(T), count) {}
123 ArrayReuse(sizeof(T), count, memory) {}
129 inline operator bool()
const {
146 return static_cast<T*
>(ArrayReuse::request());
154 inline T*
get(void) {
155 return static_cast<T*
>(ArrayReuse::get());
164 return init<T>(
static_cast<T*
>(ArrayReuse::get()));
173 inline T*
get(timeout_t timeout) {
174 return static_cast<T*
>(ArrayReuse::get(timeout));
184 return init<T>(
static_cast<T*
>(ArrayReuse::get(timeout)));
192 ArrayReuse::release(
object);
200 inline operator T*() {
235 PagerReuse(pager, sizeof(T), count) {}
241 inline operator bool()
const {
242 return PagerReuse::avail();
250 return !PagerReuse::avail();
258 inline T *
get(void) {
259 return static_cast<T*
>(PagerReuse::get());
269 return init<T>(
static_cast<T*
>(PagerReuse::get()));
278 inline T *
get(timeout_t timeout) {
279 return static_cast<T*
>(PagerReuse::get(timeout));
290 return init<T>(
static_cast<T*
>(PagerReuse::get(timeout)));
298 return static_cast<T*
>(PagerReuse::request());
306 PagerReuse::release(
object);
323 inline operator T*() {
T * create(timeout_t timeout)
Create a typed object from the heap.
Thread classes and sychronization objects.
bool operator!() const
Test if the entire heap has been allocated.
T * operator*()
Get a typed object from the heap by pointer reference.
T * create(void)
Get a typed object from the pager heap.
An array of reusable objects.
T * create(timeout_t timeout)
Create a typed object from the heap.
array_reuse(unsigned count)
Create private heap of reusable objects of specified type.
Common namespace for all ucommon objects.
bool operator!() const
Test if no objects are available for reuse or the pager.
T * create(void)
Create a typed object from the heap.
T * get(void)
Get a typed object from the pager heap.
paged_reuse(mempager *pager, unsigned count)
Create a managed reusable typed object pool.
void release(T *object)
Release (return) a typed object back to the heap for re-use.
This is a base class for objects that may be created in pager pools.
A reusable private pool of reusable types.
void release(T *object)
Release (return) a typed object back to the pager heap for re-use.
T &() limit(T &value, T &low, T &high)
Convenience macro to range restrict values.
T * request(void)
Request immediately next available typed object from the heap.
array_reuse(unsigned count, void *memory)
Create reusable objects of specific type in preallocated memory.
T * get(void)
Get a typed object from the heap.
T * operator*()
Get a typed object from the pager heap by type casting reference.
T * request(void)
Request immediately next available typed object from the pager heap.