ders::buf_cache Class Reference

Keeps large buffers of requested size which are too expensive to allocate on demand. More...

#include <buf_cache.hpp>

List of all members.

Public Member Functions

 buf_cache (int bsize)
 ~buf_cache ()
void * take_buf ()
void return_buf (mem_buf &mb)
int buf_size () const


Detailed Description

Keeps large buffers of requested size which are too expensive to allocate on demand.

Definition at line 45 of file buf_cache.hpp.


Constructor & Destructor Documentation

ders::buf_cache::buf_cache ( int  bsize  )  [inline]

Definition at line 53 of file buf_cache.hpp.

00053 : bsz(bsize) {}

ders::buf_cache::~buf_cache (  )  [inline]

Definition at line 61 of file buf_cache.hpp.

00062 {
00063  for (int i=0, end=bufs.size(); i<end; i++) operator delete(bufs[i]);
00064 }


Member Function Documentation

void * ders::buf_cache::take_buf (  )  [inline]

Definition at line 66 of file buf_cache.hpp.

00067 {
00068  if (!bufs.size()) return operator new(bsz);
00069 
00070  void* ret=bufs.back();
00071  bufs.pop_back();
00072  return ret;
00073 }

void ders::buf_cache::return_buf ( mem_buf mb  )  [inline]

Definition at line 75 of file buf_cache.hpp.

00076 {
00077  bufs.push_back(mb.get());
00078  mb.release();
00079 }

int ders::buf_cache::buf_size (  )  const [inline]

Definition at line 58 of file buf_cache.hpp.

00058 { return bsz; }


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

Generated on Tue Dec 8 11:35:32 2009 for derslib by  doxygen 1.5.5