29 #ifndef _UCOMMON_MAPPED_H_
30 #define _UCOMMON_MAPPED_H_
32 #ifndef _UCOMMON_LINKED_H_
36 #ifndef _UCOMMON_THREAD_H_
40 #ifndef _UCOMMON_STRING_H_
78 void create(
const char *name,
size_t size = (
size_t)0);
84 virtual void *invalid(
void)
const;
89 virtual void fault(
void)
const;
124 static void remove(
const char *name);
130 inline operator bool()
const
131 {
return (size != 0);}
138 {
return (size == 0);}
147 void *sbrk(
size_t size);
154 void *offset(
size_t offset)
const;
164 bool copy(
size_t offset,
void *buffer,
size_t size)
const;
170 inline size_t len(
void)
const
187 static void disable(
void);
209 inline void create(
const char *fname,
unsigned count)
225 MappedReuse(
const char *name,
size_t size,
unsigned count);
231 bool avail(
void)
const;
282 inline void create(
const char *fn,
unsigned members)
302 {
new((caddr_t)
offset(0)) T[size /
sizeof(T)];}
309 {
return sbrk(
sizeof(T));}
317 {
return static_cast<T*
>(
offset(member *
sizeof(T)));}
324 {
return static_cast<T*
>(
sbrk(
sizeof(T)));}
338 inline unsigned max(
void)
const
339 {
return (
unsigned)(size /
sizeof(T));}
372 {
new((caddr_t)
pos(0)) T[size /
sizeof(T)];}
378 inline operator bool()
const
409 inline T *
pos(
size_t member)
486 {
return static_cast<const T*
>(
offset(member *
sizeof(T)));}
496 inline volatile const T *
get(
unsigned member)
497 {
return static_cast<const T*
>(
offset(member *
sizeof(T)));}
499 inline void copy(
unsigned member, T& buffer)
507 {
return (
unsigned)(size /
sizeof(T));}
volatile const T & operator[](unsigned member)
Reference typed member object in the mapped segment.
T * getTimed(timeout_t timeout)
Request a typed reusable object from the free list or mapped space.
T * operator*()
Request a typed reusable object from the free list or mapped space by pointer reference.
ReusableObject * getTimed(timeout_t timeout)
Request a reusable object from the free list or mapped space.
T * get(void)
Request a typed reusable object from the free list or mapped space.
T * getLocked(void)
Used to get a typed object from the reuse pool when the mutex lock is already held.
bool copy(size_t offset, void *buffer, size_t size) const
Copy memory from specific offset within the mapped memory segment.
Linked objects, lists, templates, and containers.
unsigned long timeout_t
Typedef for millisecond timer values.
volatile const T * operator()(unsigned member)
Access typed member object in the mapped segment.
Common namespace for all ucommon objects.
void * offset(size_t offset) const
Get memory from a specific offset within the mapped memory segment.
Class to access a named mapped segment published from another process.
void release(ReusableObject *object)
Release resuable object.
mapped_view(const char *name)
Map existing named memory segment.
Generic non-recursive exclusive lock class.
T * request(void)
Request a typed reusable object from the free list or mapped space.
void release(SharedAccess &object)
Convenience function to unlock shared object through it's protocol.
void create(const char *name, size_t size=(size_t) 0)
Supporting function to construct a new or access an existing shared memory segment.
void removeLocked(ReusableObject *object)
Used to return an object to the reuse pool when the mutex lock is already held.
void initialize(void)
Initialize typed data in mapped array.
void release(T *object)
Used to release a typed object back to the reuse typed object pool.
T & operator[](unsigned member)
Reference typed object of vector in mapped segment.
caddr_t addr(void)
Get starting address of mapped segment.
bool avail(void) const
Check whether there are objects available to be allocated.
Template class to map typed reusable objects into shared memory heap.
void * addLock(void)
Add mapped space while holding lock for one object.
Thread classes and sychronization objects.
bool operator!() const
Test if map is inactive.
unsigned max(void) const
Get member size of typed objects that can be held in mapped vector.
bool operator!() const
Check whether there are typed objects available to be allocated.
T * operator()(void)
Allocate mapped space for one object.
Reusable objects for forming private heaps.
void initialize(void)
Initialize typed data in mapped array.
ReusableObject * get(void)
Request a reusable object from the free list or mapped space.
Map a reusable allocator over a named shared memory segment.
size_t len(void) const
Get size of mapped segment.
mapped_reuse(const char *name, unsigned number)
Construct mapped reuse array of typed objects.
void * sbrk(size_t size)
Extend size of managed heap on shared memory segment.
Template class to map typed vector into shared memory.
void removeLocked(T *object)
Used to return a typed object to the reuse pool when the mutex lock is already held.
A common string class and character string support functions.
T * operator()(unsigned member)
Get typed pointer to member object of vector in mapped segment.
ReusableObject * getLocked(void)
Used to get an object from the reuse pool when the mutex lock is already held.
Construct or access a named section of memory.
ObjectProtocol * copy(ObjectProtocol *object)
Convenience function to access object copy.
mapped_array(const char *name, unsigned number)
Construct mapped vector array of typed objects.
T * pos(size_t member)
Get typed object from a specific member offset within the mapped segment.
ReusableObject * request(void)
Request a reusable object from the free list or mapped space.
unsigned count(void) const
Get count of typed member objects held in this map.
Class for resource bound memory pools between threads.