UCommon
Protected Member Functions
ost::SharedMemPager Class Reference

The shared mempager uses a mutex to protect key access methods. More...

#include <misc.h>

Inherits ost::MemPager, and ost::Mutex.

Protected Member Functions

void * alloc (size_t size)
 Get the last memory page after locking. More...
 
void * first (size_t size)
 
void purge (void)
 Purge the memory pool while locked.
 
 SharedMemPager (size_t pagesize=4096)
 Create a mempager mutex pool. More...
 
- Protected Member Functions inherited from ucommon::memalloc
virtual void * _alloc (size_t size)
 Allocate memory from the pager heap. More...
 
page_t * pager (void)
 Acquire a new page from the heap. More...
 
void assign (memalloc &source)
 Assign foreign pager to us. More...
 
unsigned max (void) const
 Get the maximum number of pages that are permitted. More...
 
 memalloc (size_t page=0)
 Construct a memory pager. More...
 
 memalloc (const memalloc &copy)
 
unsigned pages (void) const
 Get the number of pages that have been allocated from the real heap. More...
 
void purge (void)
 Purge all allocated memory and heap pages immediately.
 
size_t size (void) const
 Get the size of a memory page. More...
 
unsigned utilization (void) const
 Determine fragmentation level of acquired heap pages. More...
 
virtual ~memalloc ()
 Destroy a memory pager. More...
 
- Protected Member Functions inherited from ucommon::MemoryProtocol
virtual void * _alloc (size_t size)=0
 Protocol to allocate memory from the pager heap. More...
 
void * alloc (size_t size)
 Convenience function. More...
 
char * dup (const char *string)
 Duplicate NULL terminated string into allocated memory. More...
 
void * dup (void *memory, size_t size)
 Duplicate existing memory block into allocated memory. More...
 
void * zalloc (size_t size)
 Allocate memory from the pager heap. More...
 
- Protected Member Functions inherited from ucommon::RecursiveMutex
virtual void _lock (void)
 
virtual void _unlock (void)
 
void lock (void)
 Acquire or increase locking.
 
bool lock (timeout_t timeout)
 Timed lock request.
 
 RecursiveMutex ()
 Create rexlock.
 
void release (void)
 Release or decrease locking.
 

Additional Inherited Members

- Public Member Functions inherited from ost::MemPager
void * alloc (size_t size)
 
char * alloc (const char *str)
 
char * first (const char *str)
 
void * first (size_t size)
 
int getPages (void) const
 
 MemPager (size_t pagesize=4096)
 
void purge (void)
 
- Public Member Functions inherited from ost::Mutex
void enter (void)
 
void enterMutex (void)
 
void leave (void)
 
void leaveMutex (void)
 
bool test (void)
 
bool tryEnterMutex (void)
 
- Protected Types inherited from ucommon::RecursiveMutex
typedef autoexclusive
< RecursiveMutex
autolock
 
- Protected Attributes inherited from ucommon::memalloc
unsigned limit
 
- Protected Attributes inherited from ucommon::RecursiveMutex
pthread_t locker
 
unsigned lockers
 
unsigned waiting
 

Detailed Description

The shared mempager uses a mutex to protect key access methods.

This class is used when a mempager will be shared by multiple threads.

Author
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org mutex protected memory pager.

Definition at line 104 of file misc.h.

Constructor & Destructor Documentation

ost::SharedMemPager::SharedMemPager ( size_t  pagesize = 4096)
protected

Create a mempager mutex pool.

Parameters
pagesizepage size for allocation.
namea name for the pool.

Member Function Documentation

void* ost::SharedMemPager::alloc ( size_t  size)
protected

Get the last memory page after locking.

Returns
allocated memory space.
Parameters
sizeof request.

The documentation for this class was generated from the following file: