Go to the documentation of this file.
30 #ifndef _UCOMMON_MAPPED_H_
31 #define _UCOMMON_MAPPED_H_
33 #ifndef _UCOMMON_LINKED_H_
37 #ifndef _UCOMMON_THREAD_H_
41 #ifndef _UCOMMON_STRING_H_
81 void create(
const char *name,
size_t size = (
size_t)0);
116 static void remove(
const char *name);
122 inline operator bool()
const
123 {
return (size != 0);}
130 {
return (size == 0);}
139 void *sbrk(
size_t size);
146 void *offset(
size_t offset)
const;
156 bool copy(
size_t offset,
void *buffer,
size_t size)
const;
162 inline size_t len(
void)
const
179 static void disable(
void);
203 inline void create(
const char *fname,
unsigned count)
219 MappedReuse(
const char *name,
size_t size,
unsigned count);
225 bool avail(
void)
const;
279 inline void create(
const char *fn,
unsigned members)
299 {
new((caddr_t)
offset(0)) T[size /
sizeof(T)];}
306 {
return sbrk(
sizeof(T));}
314 {
return static_cast<T*
>(
offset(member *
sizeof(T)));}
321 {
return static_cast<T*
>(
sbrk(
sizeof(T)));}
335 inline unsigned max(
void)
const
336 {
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)
489 {
return static_cast<const T*
>(
offset(member *
sizeof(T)));}
499 inline volatile const T *get(
unsigned member)
500 {
return static_cast<const T*
>(
offset(member *
sizeof(T)));}
502 inline void copy(
unsigned member, T& buffer)
510 {
return (
unsigned)(size /
sizeof(T));}
ReusableObject * getLocked(void)
Used to get an object from the reuse pool when the mutex lock is already held.
size_t len(void) const
Get size of mapped segment.
const volatile T * operator()(unsigned member)
Access typed member object in the mapped segment.
const volatile T & operator[](unsigned member)
Reference typed member object in the mapped segment.
mapped_view(const char *name)
Map existing named memory segment.
void release(ReusableObject *object)
Release resuable object.
unsigned count(void) const
Get count of typed member objects held in this map.
Map a reusable allocator over a named shared memory segment.
T * getTimed(timeout_t timeout)
Request a typed reusable object from the free list or mapped space.
ReusableObject * request(void)
Request a reusable object from the free list or mapped space.
T * operator()(void)
Allocate mapped space for one object.
Common namespace for all ucommon objects.
Class for resource bound memory pools between threads.
Linked objects, lists, templates, and containers.
T copy(const T &src)
Convenience function to copy objects.
mapped_reuse(const char *name, unsigned number)
Construct mapped reuse array of typed objects.
T * getLocked(void)
Used to get a typed object from the reuse pool when the mutex lock is already held.
void * offset(size_t offset) const
Get memory from a specific offset within the mapped memory segment.
Template class to map typed reusable objects into shared memory heap.
T * request(void)
Request a typed reusable object from the free list or mapped space.
ReusableObject * get(void)
Request a reusable object from the free list or mapped space.
Thread classes and sychronization objects.
mapped_array(const char *name, unsigned number)
Construct mapped vector array of typed objects.
void * addLock(void)
Add mapped space while holding lock for one object.
A common string class and character string support functions.
void removeLocked(T *object)
Used to return a typed object to the reuse pool when the mutex lock is already held.
void initialize(void)
Initialize typed data in mapped array.
Template class to map typed vector into shared memory.
Reusable objects for forming private heaps.
Construct or access a named section of memory.
T * pos(size_t member)
Get typed object from a specific member offset within the mapped segment.
unsigned max(void) const
Get member size of typed objects that can be held in mapped vector.
bool avail(void) const
Check whether there are objects available to be allocated.
Class to access a named mapped segment published from another process.
T * operator*()
Request a typed reusable object from the free list or mapped space by pointer reference.
bool operator!() const
Test if map is inactive.
void * sbrk(size_t size)
Extend size of managed heap on shared memory segment.
bool operator!() const
Check whether there are typed objects available to be allocated.
bool copy(size_t offset, void *buffer, size_t size) const
Copy memory from specific offset within the mapped memory segment.
void release(T *object)
Used to release a typed object back to the reuse typed object pool.
Generic non-recursive exclusive lock class.
void initialize(void)
Initialize typed data in mapped array.
const struct sockaddr * addr(Socket::address &address)
A convenience function to convert a socket address list into a socket address.
ReusableObject * getTimed(timeout_t timeout)
Request a reusable object from the free list or mapped space.
T & operator[](unsigned member)
Reference typed object of vector in mapped segment.
void create(const char *name, size_t size=(size_t) 0)
Supporting function to construct a new or access an existing shared memory segment.
T * get(void)
Request a typed reusable object from the free list or mapped space.
void removeLocked(ReusableObject *object)
Used to return an object to the reuse pool when the mutex lock is already held.
T * operator()(unsigned member)
Get typed pointer to member object of vector in mapped segment.