ucommon  7.0.0
About: GNU uCommon C++ is a portable and optimized class framework for writing C++ applications that need to use threads and support concurrent synchronization, and that use sockets, XML parsing, object serialization, thread-optimized string and data structure classes, etc..
  Fossies Dox: ucommon-7.0.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

No Matches
ost::SharedMemPager Class Reference

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

#include <misc.h>

Inheritance diagram for ost::SharedMemPager:
Collaboration diagram for ost::SharedMemPager:

Protected Member Functions

 SharedMemPager (size_t pagesize=4096)
 Create a mempager mutex pool. More...
void purge (void)
 Purge the memory pool while locked. More...
void * alloc (size_t size)
 Get the last memory page after locking. More...
void * first (size_t size)
- Protected Member Functions inherited from ucommon::memalloc
page_tpager (void)
 Acquire a new page from the heap. More...
virtual void * _alloc (size_t size) __OVERRIDE
 Allocate memory from the pager heap. More...
 memalloc (size_t page=0)
 Construct a memory pager. More...
 memalloc (const memalloc &copy)
virtual ~memalloc ()
 Destroy a memory pager. More...
unsigned pages (void) const
 Get the number of pages that have been allocated from the real heap. More...
unsigned max (void) const
 Get the maximum number of pages that are permitted. More...
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...
void purge (void)
 Purge all allocated memory and heap pages immediately. More...
void assign (memalloc &source)
 Assign foreign pager to us. More...
- Protected Member Functions inherited from ucommon::RecursiveMutex
virtual void _lock (void) __OVERRIDE
virtual void _unlock (void) __OVERRIDE
 RecursiveMutex ()
 Create rexlock. More...
void lock (void)
 Acquire or increase locking. More...
bool lock (timeout_t timeout)
 Timed lock request. More...
void release (void)
 Release or decrease locking. More...

Private Member Functions

 __DELETE_COPY (SharedMemPager)

Additional Inherited Members

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

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.

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

◆ SharedMemPager()

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

Create a mempager mutex pool.

pagesizepage size for allocation.
namea name for the pool.

Definition at line 108 of file misc.cpp.

Member Function Documentation


ost::SharedMemPager::__DELETE_COPY ( SharedMemPager  )

◆ alloc()

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

Get the last memory page after locking.

allocated memory space.
sizeof request.

Definition at line 119 of file misc.cpp.

References ost::MemPager::alloc(), ost::Mutex::enterMutex(), ost::Mutex::leaveMutex(), and ucommon::memalloc::size().

Here is the call graph for this function:

◆ first()

void * ost::SharedMemPager::first ( size_t  size)

Definition at line 130 of file misc.h.

◆ purge()

void ost::SharedMemPager::purge ( void  )

Purge the memory pool while locked.

Definition at line 112 of file misc.cpp.

References ost::Mutex::enterMutex(), ost::Mutex::leaveMutex(), and ost::MemPager::purge().

Here is the call graph for this function:

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