The shared mempager uses a mutex to protect key access methods.
More...
#include <misc.h>
Inheritance diagram for SharedMemPager:
Collaboration diagram for SharedMemPager:
Public Member Functions
Return the total number of pages that have been allocated for this memory pool.
More...
Enable setting of mutex name for deadlock debug.
More...
Entering a
Mutex locks the mutex for the current thread.
More...
Future abi will use enter/leave/test members.
More...
Future abi will use enter/leave/test members.
More...
Future abi will use enter/leave/test members.
More...
Tries to lock the mutex for the current thread.
More...
Leaving a mutex frees that mutex for use by another thread.
More...
Static Public Member Functions
Enable or disable deadlock debugging.
More...
Protected Member Functions
Create a mempager mutex pool.
More...
Purge the memory pool while locked.
More...
void *
first (size_t size)
Get the first memory page after locking.
More...
void *
alloc (size_t size)
Get the last memory page after locking.
More...
Allocate a string from the memory pager pool and copy the string into it's new memory area.
More...
char *
alloc (const char *str)
Allocate a string from the memory pager pool and copy the string inti it's new memory area.
More...
Clean for memory cleanup before exiting.
More...
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.@ost.nosp@m.el.co.nosp@m.m mutex protected memory pager.
Definition at line 250 of file misc.h.
Constructor & Destructor Documentation
SharedMemPager::SharedMemPager
(
size_t
pagesize = 4096
,
const char *
name = NULL
)
protected
Create a mempager mutex pool.
- Parameters
-
pagesize page size for allocation.
name a name for the pool.
Member Function Documentation
char* MemPager::alloc
(
const char *
str )
protectedinherited
Allocate a string from the memory pager pool and copy the string inti it's new memory area.
This checks only the last active page for available space before allocating a new page.
- Parameters
-
str string to allocate and copy into paged memory pool.
- Returns
- copy of string from allocated memory.
void* SharedMemPager::alloc
(
size_t
size )
protectedvirtual
Get the last memory page after locking.
- Returns
- allocated memory space.
- Parameters
-
size of request.
Reimplemented from MemPager.
void MemPager::clean
(
void
)
protectedinherited
Clean for memory cleanup before exiting.
void Mutex::enter
(
void
)
inlineinherited
Future abi will use enter/leave/test members.
Definition at line 263 of file thread.h.
void Mutex::enterMutex
(
void
)
inherited
Entering a Mutex locks the mutex for the current thread.
This also can be done using the ENTER_CRITICAL macro or by using the ++ operator on a mutex.
- See Also
- leaveMutex
char* MemPager::first
(
char *
str )
protectedinherited
Allocate a string from the memory pager pool and copy the string into it's new memory area.
This method allocates memory by first searching for an available page, and then allocating a new page if no space is found.
- Parameters
-
str string to allocate and copy into paged memory pool.
- Returns
- copy of string from allocated memory.
void* SharedMemPager::first
(
size_t
size )
protectedvirtual
Get the first memory page after locking.
- Returns
- allocated memory space.
- Parameters
-
size of request.
Reimplemented from MemPager.
int MemPager::getPages
(
void
)
inlineinherited
Return the total number of pages that have been allocated for this memory pool.
- Returns
- number of pages allocated.
Definition at line 181 of file misc.h.
void Mutex::leave
(
void
)
inlineinherited
Future abi will use enter/leave/test members.
Definition at line 269 of file thread.h.
void Mutex::leaveMutex
(
void
)
inherited
Leaving a mutex frees that mutex for use by another thread.
If the mutex has been entered (invoked) multiple times (recursivily) by the same thread, then it will need to be exited the same number of instances before it is free for re-use. This operation can also be done using the LEAVE_CRITICAL macro or by the – operator on a mutex.
- See Also
- enterMutex
void Mutex::nameMutex
(
const char *
name )
inlineinherited
Enable setting of mutex name for deadlock debug.
- Parameters
-
name for mutex.
Definition at line 248 of file thread.h.
void SharedMemPager::purge
(
void
)
protected
Purge the memory pool while locked.
static void Mutex::setDebug
(
bool
mode )
inlinestaticinherited
Enable or disable deadlock debugging.
- Parameters
-
mode debug mode.
Definition at line 240 of file thread.h.
bool Mutex::test
(
void
)
inlineinherited
Future abi will use enter/leave/test members.
- Returns
- true if entered.
Definition at line 277 of file thread.h.
bool Mutex::tryEnterMutex
(
void
)
inherited
Tries to lock the mutex for the current thread.
Behaves like enterMutex , except that it doesn't block the calling thread if the mutex is already locked by another thread.
- Returns
- true if locking the mutex was succesful otherwise false
- See Also
- enterMutex
-
leaveMutex
The documentation for this class was generated from the following file: