Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

Pool< T > Class Template Reference

Pool of pre-allocated memory. More...

#include <LinkedList.hpp>

List of all members.

Public Member Functions

 Pool ()
 ~Pool ()
std::size_t Allocated () const
std::size_t ChunkSize () const
ListNode< T > * Get () volatile
 Grabs memory from pool in threadsafe manner.
void AddToDeadList (ListNode< T > *node) volatile
 Adds a node to the list of dead nodes in a threadsafe manner.
void Put (ListNode< T > *node)
 Puts node back on pool, not threadsafe.
void RaiseTheDead ()
 Returns dead nodes to pool.

Static Public Attributes

static const std::size_t CHUNK_SIZE = 1 << 24

Private Member Functions

void Allocate ()

Private Attributes

ListNode< T > * m_head
ListNode< T > * m_dead
bool m_lockedHead
bool m_lockedDead
std::size_t m_allocated
std::size_t m_chunkSize
std::vector< ListNode< T > * > m_chunks

Detailed Description

template<typename T>
class Pool< T >

Pool of pre-allocated memory.

Allocates more memory when current amount is used up.

Definition at line 145 of file LinkedList.hpp.


Constructor & Destructor Documentation

template<typename T >
Pool< T >::Pool (  )  [inline]

Definition at line 190 of file LinkedList.hpp.

References Pool< T >::Allocate().

template<typename T >
Pool< T >::~Pool (  )  [inline]

Definition at line 202 of file LinkedList.hpp.

References Pool< T >::m_chunks.


Member Function Documentation

template<typename T >
void Pool< T >::AddToDeadList ( ListNode< T > *  node  )  volatile [inline]

Adds a node to the list of dead nodes in a threadsafe manner.

Definition at line 251 of file LinkedList.hpp.

References Pool< T >::m_dead, ListNode< T >::m_dead, and Pool< T >::m_lockedDead.

template<typename T >
void Pool< T >::Allocate (  )  [inline, private]
template<typename T >
std::size_t Pool< T >::Allocated (  )  const [inline]

Definition at line 209 of file LinkedList.hpp.

References Pool< T >::m_allocated.

template<typename T >
std::size_t Pool< T >::ChunkSize (  )  const [inline]

Definition at line 215 of file LinkedList.hpp.

References Pool< T >::m_chunkSize.

template<typename T >
ListNode< T > * Pool< T >::Get (  )  volatile [inline]

Grabs memory from pool in threadsafe manner.

Definition at line 235 of file LinkedList.hpp.

References Pool< T >::Allocate(), Pool< T >::m_head, and Pool< T >::m_lockedHead.

template<typename T >
void Pool< T >::Put ( ListNode< T > *  node  )  [inline]

Puts node back on pool, not threadsafe.

Definition at line 274 of file LinkedList.hpp.

References Pool< T >::m_head, and ListNode< T >::m_next.

Referenced by Pool< T >::RaiseTheDead().

template<typename T >
void Pool< T >::RaiseTheDead (  )  [inline]

Returns dead nodes to pool.

Definition at line 260 of file LinkedList.hpp.

References ListNode< T >::m_dead, Pool< T >::m_dead, and Pool< T >::Put().


Member Data Documentation

template<typename T>
const std::size_t Pool< T >::CHUNK_SIZE = 1 << 24 [static]

Definition at line 149 of file LinkedList.hpp.

template<typename T>
std::size_t Pool< T >::m_allocated [private]

Definition at line 180 of file LinkedList.hpp.

Referenced by Pool< T >::Allocate(), and Pool< T >::Allocated().

template<typename T>
std::vector<ListNode<T>* > Pool< T >::m_chunks [private]

Definition at line 184 of file LinkedList.hpp.

Referenced by Pool< T >::Allocate(), and Pool< T >::~Pool().

template<typename T>
std::size_t Pool< T >::m_chunkSize [private]

Definition at line 182 of file LinkedList.hpp.

Referenced by Pool< T >::Allocate(), and Pool< T >::ChunkSize().

template<typename T>
ListNode<T>* Pool< T >::m_dead [private]

Definition at line 174 of file LinkedList.hpp.

Referenced by Pool< T >::AddToDeadList(), and Pool< T >::RaiseTheDead().

template<typename T>
ListNode<T>* Pool< T >::m_head [private]

Definition at line 172 of file LinkedList.hpp.

Referenced by Pool< T >::Allocate(), Pool< T >::Get(), and Pool< T >::Put().

template<typename T>
bool Pool< T >::m_lockedDead [private]

Definition at line 178 of file LinkedList.hpp.

Referenced by Pool< T >::AddToDeadList().

template<typename T>
bool Pool< T >::m_lockedHead [private]

Definition at line 176 of file LinkedList.hpp.

Referenced by Pool< T >::Get().


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


6 Jan 2011 Doxygen 1.6.3