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));}
mapped_array(const char *name, unsigned number)
Construct mapped vector array of typed objects.
void release(ReusableObject *object)
Release resuable object.
void * offset(size_t offset) const
Get memory from a specific offset within the mapped memory segment.
A common string class and character string support functions.
void initialize(void)
Initialize typed data in mapped array.
bool avail(void) const
Check whether there are objects available to be allocated.
Reusable objects for forming private heaps.
mapped_reuse(const char *name, unsigned number)
Construct mapped reuse array of typed objects.
size_t len(void) const
Get size of mapped segment.
T * pos(size_t member)
Get typed object from a specific member offset within the mapped segment.
Thread classes and sychronization objects.
Generic non-recursive exclusive lock class.
void removeLocked(ReusableObject *object)
Used to return an object to the reuse pool when the mutex lock is already held.
Class to access a named mapped segment published from another process.
void initialize(void)
Initialize typed data in mapped array.
T & operator[](unsigned member)
Reference typed object of vector in mapped segment.
Common namespace for all ucommon objects.
Class for resource bound memory pools between threads.
bool operator!() const
Check whether there are typed objects available to be allocated.
ReusableObject * request(void)
Request a reusable object from the free list or mapped space.
T * operator()(void)
Allocate mapped space for one object.
T * get(void)
Request a typed reusable object from the free list or mapped space.
const volatile T * operator()(unsigned member)
Access typed member object in the mapped segment.
T copy(const T &src)
Convenience function to copy objects.
ReusableObject * getLocked(void)
Used to get an object from the reuse pool when the mutex lock is already held.
void * addLock(void)
Add mapped space while holding lock for one object.
unsigned max(void) const
Get member size of typed objects that can be held in mapped vector.
const struct sockaddr * addr(Socket::address &address)
A convenience function to convert a socket address list into a socket address.
bool operator!() const
Test if map is inactive.
void create(const char *name, size_t size=(size_t) 0)
Supporting function to construct a new or access an existing shared memory segment.
Linked objects, lists, templates, and containers.
ReusableObject * get(void)
Request a reusable object from the free list or mapped space.
T * getTimed(timeout_t timeout)
Request a typed reusable object from the free list or mapped space.
Template class to map typed reusable objects into shared memory heap.
const volatile T & operator[](unsigned member)
Reference typed member object in the mapped segment.
void * sbrk(size_t size)
Extend size of managed heap on shared memory segment.
Map a reusable allocator over a named shared memory segment.
bool copy(size_t offset, void *buffer, size_t size) const
Copy memory from specific offset within the mapped memory segment.
T * operator*()
Request a typed reusable object from the free list or mapped space by pointer reference.
T * operator()(unsigned member)
Get typed pointer to member object of vector in mapped segment.
mapped_view(const char *name)
Map existing named memory segment.
T * request(void)
Request a typed reusable object from the free list or mapped space.
Template class to map typed vector into shared memory.
unsigned count(void) const
Get count of typed member objects held in this map.
T * getLocked(void)
Used to get a typed object from the reuse pool when the mutex lock is already held.
ReusableObject * getTimed(timeout_t timeout)
Request a reusable object from the free list or mapped space.
Construct or access a named section of memory.
void release(T *object)
Used to release a typed object back to the reuse typed object pool.
void removeLocked(T *object)
Used to return a typed object to the reuse pool when the mutex lock is already held.