The StackPager provides a repository to stash and retrieve working data in last-in-first-out order.
More...
#include <misc.h>
|
| StackPager (size_t pagesize) |
| Create a lifo pager as a mempager. More...
|
|
void * | push (const void *object, size_t size) |
| Push an arbitrary object onto the stack. More...
|
|
void * | push (const char *string) |
| Push a string onto the stack. More...
|
|
void * | pull (void) |
| Retrieve next object from stack. More...
|
|
void | purge (void) |
| Purge the stack of all objects and memory allocations. More...
|
|
|
virtual void * | first (size_t size) |
| Allocate first workspace from paged memory. More...
|
|
char * | first (char *str) |
| Allocate a string from the memory pager pool and copy the string into it's new memory area. More...
|
|
virtual void * | alloc (size_t size) |
| Allocate memory from either the currently active page, or allocate a new page for the object. 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...
|
|
void | clean (void) |
| Clean for memory cleanup before exiting. More...
|
|
int | getPages (void) |
| Return the total number of pages that have been allocated for this memory pool. More...
|
|
The StackPager provides a repository to stash and retrieve working data in last-in-first-out order.
The use of a mempager to support it's operation allows storage of arbitrary sized objects with no fixed limit.
- Author
- David Sugar dyfet.nosp@m.@ost.nosp@m.el.co.nosp@m.m last in first out object pager.
Definition at line 194 of file misc.h.
StackPager::StackPager |
( |
size_t |
pagesize | ) |
|
Create a lifo pager as a mempager.
- Parameters
-
pagesize | for memory allocation |
virtual void* MemPager::alloc |
( |
size_t |
size | ) |
|
|
protectedvirtualinherited |
Allocate memory from either the currently active page, or allocate a new page for the object.
- Parameters
-
size | size of memory to allocate. |
- Returns
- pointer to allocated memory.
Reimplemented in SharedMemPager.
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 MemPager::clean |
( |
void |
| ) |
|
|
protectedinherited |
Clean for memory cleanup before exiting.
virtual void* MemPager::first |
( |
size_t |
size | ) |
|
|
protectedvirtualinherited |
Allocate first workspace from paged memory.
This method scans all currently allocated blocks for available space before adding new pages and hence is both slower and more efficient.
- Parameters
-
size | size of memory to allocate. |
- Returns
- pointer to allocated memory.
Reimplemented in SharedMemPager.
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.
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* StackPager::pull |
( |
void |
| ) |
|
Retrieve next object from stack.
- Returns
- object.
void StackPager::purge |
( |
void |
| ) |
|
Purge the stack of all objects and memory allocations.
void* StackPager::push |
( |
const void * |
object, |
|
|
size_t |
size |
|
) |
| |
Push an arbitrary object onto the stack.
- Returns
- stack memory location.
- Parameters
-
object | pointer to data |
size | of data. |
void* StackPager::push |
( |
const char * |
string | ) |
|
Push a string onto the stack.
- Returns
- stack memory location.
- Parameters
-
The documentation for this class was generated from the following file: