Public Member Functions

kNet::LockFreePoolAllocator< T > Class Template Reference

T must implement PoolAllocatable. More...

#include <LockFreePoolAllocator.h>

List of all members.

Public Member Functions

T * New ()
 Allocates a new object of type T and returns a pointer to it.
void ClearAll ()
 Deallocates all cached unused nodes in this pool.
void UnsafeClearAll ()
 A fast method to free all items allocated in the pool.
bool DebugHasCycle ()
 A debugging function that checks whether the underlying linked list has a cycle or not. Not thread-safe!
void DumpPool ()
 A debugging function that prints out all the objects in the pool. Not thread-safe!

Detailed Description

template<typename T>
class kNet::LockFreePoolAllocator< T >

T must implement PoolAllocatable.


Member Function Documentation

template<typename T>
T* kNet::LockFreePoolAllocator< T >::New (  )  [inline]

Allocates a new object of type T and returns a pointer to it.

Call Free() to deallocate the object.

Referenced by kNet::MessageConnection::AllocateNewMessage().

template<typename T>
void kNet::LockFreePoolAllocator< T >::ClearAll (  )  [inline]

Deallocates all cached unused nodes in this pool.

Thread-safe and lock-free. If you are manually tearing down the pool and there are no other threads accessing this, you may call the even faster version UnsafeClearAll(), which ignores compare-and-swap updates.

template<typename T>
void kNet::LockFreePoolAllocator< T >::UnsafeClearAll (  )  [inline]

A fast method to free all items allocated in the pool.

Not thread-safe, only call when you can guarantee there are no threads calling New() or Free().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines