mem_pool Class Reference

#include <memory_pool.hh>

Inheritance diagram for mem_pool:
Inheritance graph
[legend]

Public Member Functions

virtual bool init (unsigned long maxsize)=0
void * alloc (unsigned long size)
__inline__ void reset ()
__inline__ unsigned long get_curpos ()
__inline__ void * get_mem ()

Detailed Description

class mem_pool

memory allocator to share a pool between streams.


Member Function Documentation

void* mem_pool::alloc ( unsigned long  size  )  [inline]

Allocate the given size of memory.

Parameters:
size size of buffer to allocate.
Returns:
Starting pointer to the buffer.

00035         {
00036                 if(size+curpos_ > maxsize_)
00037                         return 0;
00038                 curpos_ = ALIGN(curpos_, 64);
00039                 void * ret = (void *) (mem_ + curpos_);
00040                 curpos_ += size;
00041                 curpos_ = ALIGN(curpos_, 64);
00042                 return ret;
00043         }

Here is the caller graph for this function:

__inline__ unsigned long mem_pool::get_curpos (  )  [inline]

Retrieve the current position in the pool. In other words, size of total amount of memory allocated.

Returns:
Current position in the memory pool.

00060 { return curpos_; }

__inline__ void* mem_pool::get_mem (  )  [inline]

Retrieve the starting point of the pool buffer.

Returns:
Starting point of the pool buffer.

00067 { return mem_; }

virtual bool mem_pool::init ( unsigned long  maxsize  )  [pure virtual]
Parameters:
maxsize 
Returns:

Implemented in cuda_mem_pool, and pinned_mem_pool.

__inline__ void mem_pool::reset (  )  [inline]

Reset buffer pool. In other words invalidate all allocation from the pool

00050         {
00051                 curpos_ = 0;
00052         }

 All Data Structures Functions
Generated on Tue Oct 18 10:20:21 2011 for libgpucrypto by  doxygen 1.6.3