
#include <DS_ThreadsafeAllocatingQueue.h>

Public Member Functions | |
| structureType * | Allocate (const char *file, unsigned int line) |
| void | Clear (const char *file, unsigned int line) |
| void | Deallocate (structureType *s, const char *file, unsigned int line) |
| structureType * | Pop (void) |
| structureType * | PopInaccurate (void) |
| void | Push (structureType *s) |
| void | SetPageSize (int size) |
Protected Attributes | |
| MemoryPool< structureType > | memoryPool |
| SimpleMutex | memoryPoolMutex |
| Queue< structureType * > | queue |
| SimpleMutex | queueMutex |
Definition at line 22 of file DS_ThreadsafeAllocatingQueue.h.
| structureType * DataStructures::ThreadsafeAllocatingQueue< structureType >::Allocate | ( | const char * | file, | |
| unsigned int | line | |||
| ) |
Definition at line 82 of file DS_ThreadsafeAllocatingQueue.h.
References DataStructures::MemoryPool< MemoryBlockType >::Allocate(), SimpleMutex::Lock(), DataStructures::ThreadsafeAllocatingQueue< structureType >::memoryPool, DataStructures::ThreadsafeAllocatingQueue< structureType >::memoryPoolMutex, and SimpleMutex::Unlock().
Referenced by RakPeer::ChangeSystemAddress(), RakPeer::CloseConnectionInternal(), RakPeer::GetSocket(), RakPeer::GetSockets(), RecvFromLoop(), RakPeer::RunUpdateCycle(), RakPeer::SendBuffered(), RakPeer::SendBufferedList(), and UpdateTCPInterfaceLoop().
{
structureType *s;
memoryPoolMutex.Lock();
s=memoryPool.Allocate(file, line);
memoryPoolMutex.Unlock();
// Call new operator, memoryPool doesn't do this
s = new ((void*)s) structureType;
return s;
}
| void DataStructures::ThreadsafeAllocatingQueue< structureType >::Clear | ( | const char * | file, | |
| unsigned int | line | |||
| ) |
Definition at line 103 of file DS_ThreadsafeAllocatingQueue.h.
References DataStructures::MemoryPool< MemoryBlockType >::Clear(), DataStructures::Queue< queue_type >::Clear(), SimpleMutex::Lock(), DataStructures::ThreadsafeAllocatingQueue< structureType >::memoryPool, DataStructures::ThreadsafeAllocatingQueue< structureType >::memoryPoolMutex, DataStructures::ThreadsafeAllocatingQueue< structureType >::queue, DataStructures::MemoryPool< MemoryBlockType >::Release(), DataStructures::Queue< queue_type >::Size(), and SimpleMutex::Unlock().
Referenced by RakPeer::ClearBufferedCommands(), RakPeer::ClearBufferedPackets(), RakPeer::ClearSocketQueryOutput(), and TCPInterface::Stop().
{
memoryPoolMutex.Lock();
for (unsigned int i=0; i < queue.Size(); i++)
{
queue[i]->~structureType();
memoryPool.Release(queue[i], file, line);
}
queue.Clear(file, line);
memoryPoolMutex.Unlock();
memoryPoolMutex.Lock();
memoryPool.Clear(file, line);
memoryPoolMutex.Unlock();
}
| void DataStructures::ThreadsafeAllocatingQueue< structureType >::Deallocate | ( | structureType * | s, | |
| const char * | file, | |||
| unsigned int | line | |||
| ) |
Definition at line 93 of file DS_ThreadsafeAllocatingQueue.h.
References SimpleMutex::Lock(), DataStructures::ThreadsafeAllocatingQueue< structureType >::memoryPool, DataStructures::ThreadsafeAllocatingQueue< structureType >::memoryPoolMutex, DataStructures::MemoryPool< MemoryBlockType >::Release(), and SimpleMutex::Unlock().
Referenced by RakPeer::ClearBufferedCommands(), RakPeer::ClearBufferedPackets(), TCPInterface::DeallocatePacket(), RakPeer::GetSocket(), RakPeer::GetSockets(), TCPInterface::HasLostConnection(), TCPInterface::HasNewIncomingConnection(), RecvFromLoop(), RakPeer::RunUpdateCycle(), and RakPeer::SendBuffered().
{
// Call delete operator, memory pool doesn't do this
s->~structureType();
memoryPoolMutex.Lock();
memoryPool.Release(s, file, line);
memoryPoolMutex.Unlock();
}
| structureType * DataStructures::ThreadsafeAllocatingQueue< structureType >::Pop | ( | void | ) |
Definition at line 67 of file DS_ThreadsafeAllocatingQueue.h.
References DataStructures::Queue< queue_type >::IsEmpty(), SimpleMutex::Lock(), DataStructures::Queue< queue_type >::Pop(), DataStructures::ThreadsafeAllocatingQueue< structureType >::queue, DataStructures::ThreadsafeAllocatingQueue< structureType >::queueMutex, and SimpleMutex::Unlock().
Referenced by RakPeer::ClearBufferedCommands(), RakPeer::ClearBufferedPackets(), RakPeer::GetSocket(), and RakPeer::GetSockets().
{
structureType *s;
queueMutex.Lock();
if (queue.IsEmpty())
{
queueMutex.Unlock();
return 0;
}
s=queue.Pop();
queueMutex.Unlock();
return s;
}
| structureType * DataStructures::ThreadsafeAllocatingQueue< structureType >::PopInaccurate | ( | void | ) |
Definition at line 52 of file DS_ThreadsafeAllocatingQueue.h.
References DataStructures::Queue< queue_type >::IsEmpty(), SimpleMutex::Lock(), DataStructures::Queue< queue_type >::Pop(), DataStructures::ThreadsafeAllocatingQueue< structureType >::queue, DataStructures::ThreadsafeAllocatingQueue< structureType >::queueMutex, and SimpleMutex::Unlock().
Referenced by TCPInterface::HasLostConnection(), TCPInterface::HasNewIncomingConnection(), TCPInterface::Receive(), and RakPeer::RunUpdateCycle().
{
structureType *s;
if (queue.IsEmpty())
return 0;
queueMutex.Lock();
if (queue.IsEmpty()==false)
s=queue.Pop();
else
s=0;
queueMutex.Unlock();
return s;
}
| void DataStructures::ThreadsafeAllocatingQueue< structureType >::Push | ( | structureType * | s | ) |
Definition at line 44 of file DS_ThreadsafeAllocatingQueue.h.
References SimpleMutex::Lock(), DataStructures::Queue< queue_type >::Push(), DataStructures::ThreadsafeAllocatingQueue< structureType >::queue, DataStructures::ThreadsafeAllocatingQueue< structureType >::queueMutex, and SimpleMutex::Unlock().
Referenced by RakPeer::ChangeSystemAddress(), RakPeer::CloseConnectionInternal(), RakPeer::GetSocket(), RakPeer::GetSockets(), RecvFromLoop(), RakPeer::RunUpdateCycle(), RakPeer::SendBuffered(), RakPeer::SendBufferedList(), and UpdateTCPInterfaceLoop().
{
queueMutex.Lock();
queue.Push(s, __FILE__, __LINE__ );
queueMutex.Unlock();
}
| void DataStructures::ThreadsafeAllocatingQueue< structureType >::SetPageSize | ( | int | size | ) |
Definition at line 119 of file DS_ThreadsafeAllocatingQueue.h.
References DataStructures::ThreadsafeAllocatingQueue< structureType >::memoryPool, and DataStructures::MemoryPool< MemoryBlockType >::SetPageSize().
Referenced by RakPeer::RakPeer().
{
memoryPool.SetPageSize(size);
}
MemoryPool<structureType> DataStructures::ThreadsafeAllocatingQueue< structureType >::memoryPool [protected] |
Definition at line 37 of file DS_ThreadsafeAllocatingQueue.h.
Referenced by DataStructures::ThreadsafeAllocatingQueue< structureType >::Allocate(), DataStructures::ThreadsafeAllocatingQueue< structureType >::Clear(), DataStructures::ThreadsafeAllocatingQueue< structureType >::Deallocate(), and DataStructures::ThreadsafeAllocatingQueue< structureType >::SetPageSize().
SimpleMutex DataStructures::ThreadsafeAllocatingQueue< structureType >::memoryPoolMutex [protected] |
Queue<structureType*> DataStructures::ThreadsafeAllocatingQueue< structureType >::queue [protected] |
Definition at line 39 of file DS_ThreadsafeAllocatingQueue.h.
Referenced by DataStructures::ThreadsafeAllocatingQueue< structureType >::Clear(), DataStructures::ThreadsafeAllocatingQueue< structureType >::Pop(), DataStructures::ThreadsafeAllocatingQueue< structureType >::PopInaccurate(), and DataStructures::ThreadsafeAllocatingQueue< structureType >::Push().
SimpleMutex DataStructures::ThreadsafeAllocatingQueue< structureType >::queueMutex [protected] |
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.