Pool of pre-allocated memory. More...
#include <LinkedList.hpp>
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 |
Pool of pre-allocated memory.
Allocates more memory when current amount is used up.
Definition at line 145 of file LinkedList.hpp.
Definition at line 190 of file LinkedList.hpp.
References Pool< T >::Allocate().
Definition at line 202 of file LinkedList.hpp.
References Pool< T >::m_chunks.
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.
void Pool< T >::Allocate | ( | ) | [inline, private] |
Definition at line 221 of file LinkedList.hpp.
References Pool< T >::m_allocated, Pool< T >::m_chunks, Pool< T >::m_chunkSize, Pool< T >::m_head, and ListNode< T >::m_next.
Referenced by Pool< T >::Get(), and Pool< T >::Pool().
std::size_t Pool< T >::Allocated | ( | ) | const [inline] |
Definition at line 209 of file LinkedList.hpp.
References Pool< T >::m_allocated.
std::size_t Pool< T >::ChunkSize | ( | ) | const [inline] |
Definition at line 215 of file LinkedList.hpp.
References Pool< T >::m_chunkSize.
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.
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().
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().
const std::size_t Pool< T >::CHUNK_SIZE = 1 << 24 [static] |
Definition at line 149 of file LinkedList.hpp.
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().
Definition at line 184 of file LinkedList.hpp.
Referenced by Pool< T >::Allocate(), and Pool< T >::~Pool().
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().
Definition at line 174 of file LinkedList.hpp.
Referenced by Pool< T >::AddToDeadList(), and Pool< T >::RaiseTheDead().
Definition at line 172 of file LinkedList.hpp.
Referenced by Pool< T >::Allocate(), Pool< T >::Get(), and Pool< T >::Put().
bool Pool< T >::m_lockedDead [private] |
Definition at line 178 of file LinkedList.hpp.
Referenced by Pool< T >::AddToDeadList().
bool Pool< T >::m_lockedHead [private] |
Definition at line 176 of file LinkedList.hpp.
Referenced by Pool< T >::Get().