OregonCore  revision 3611e8a-git
Your Favourite TBC server
ACE_Based::LockedQueue< T, LockType, StorageType > Class Template Reference

#include <LockedQueue.h>

Public Member Functions

 LockedQueue ()
 
virtual ~LockedQueue ()
 
void add (const T &item)
 
bool next (T &result)
 
T & peek ()
 
void cancel ()
 
bool cancelled ()
 
void lock ()
 
void unlock ()
 
void pop_front ()
 
bool empty ()
 

Private Attributes

LockType _lock
 
StorageType _queue
 
volatile bool _canceled
 

Detailed Description

template<class T, class LockType, typename StorageType = std::deque<T>>
class ACE_Based::LockedQueue< T, LockType, StorageType >

Definition at line 30 of file LockedQueue.h.

Constructor & Destructor Documentation

template<class T, class LockType, typename StorageType = std::deque<T>>
ACE_Based::LockedQueue< T, LockType, StorageType >::LockedQueue ( )
inline

Definition at line 44 of file LockedQueue.h.

45  : _canceled(false)
46  {
47  }
volatile bool _canceled
Definition: LockedQueue.h:39
template<class T, class LockType, typename StorageType = std::deque<T>>
virtual ACE_Based::LockedQueue< T, LockType, StorageType >::~LockedQueue ( )
inlinevirtual

Definition at line 50 of file LockedQueue.h.

51  {
52  }

Member Function Documentation

template<class T, class LockType, typename StorageType = std::deque<T>>
void ACE_Based::LockedQueue< T, LockType, StorageType >::add ( const T &  item)
inline

Definition at line 55 of file LockedQueue.h.

Referenced by World::AddSession(), and WorldSession::QueuePacket().

56  {
57  lock();
58 
59  //ASSERT(!this->_canceled);
60  //throw Cancellation_Exception();
61 
62  _queue.push_back(item);
63 
64  unlock();
65  }
template<class T, class LockType, typename StorageType = std::deque<T>>
void ACE_Based::LockedQueue< T, LockType, StorageType >::cancel ( )
inline

Definition at line 95 of file LockedQueue.h.

96  {
97  lock();
98 
99  _canceled = true;
100 
101  unlock();
102  }
volatile bool _canceled
Definition: LockedQueue.h:39
template<class T, class LockType, typename StorageType = std::deque<T>>
bool ACE_Based::LockedQueue< T, LockType, StorageType >::cancelled ( )
inline

Definition at line 105 of file LockedQueue.h.

106  {
107  ACE_Guard<LockType> g(this->_lock);
108  return _canceled;
109  }
volatile bool _canceled
Definition: LockedQueue.h:39
template<class T, class LockType, typename StorageType = std::deque<T>>
bool ACE_Based::LockedQueue< T, LockType, StorageType >::empty ( )
inline

Definition at line 131 of file LockedQueue.h.

132  {
133  ACE_GUARD_RETURN (LockType, g, this->_lock, false);
134  return _queue.empty();
135  }
LockType
template<class T, class LockType, typename StorageType = std::deque<T>>
void ACE_Based::LockedQueue< T, LockType, StorageType >::lock ( )
inline
template<class T, class LockType, typename StorageType = std::deque<T>>
bool ACE_Based::LockedQueue< T, LockType, StorageType >::next ( T &  result)
inline

Definition at line 68 of file LockedQueue.h.

Referenced by World::ProcessCliCommands(), WorldSession::Update(), World::UpdateSessions(), World::~World(), and WorldSession::~WorldSession().

69  {
70  // ACE_Guard<LockType> g(this->_lock);
71  ACE_GUARD_RETURN (LockType, g, this->_lock, false);
72 
73  if (_queue.empty())
74  return false;
75 
76  //ASSERT (!_queue.empty() || !this->_canceled);
77  //throw Cancellation_Exception();
78  result = _queue.front();
79  _queue.pop_front();
80 
81  return true;
82  }
LockType
template<class T, class LockType, typename StorageType = std::deque<T>>
T& ACE_Based::LockedQueue< T, LockType, StorageType >::peek ( )
inline

Definition at line 85 of file LockedQueue.h.

86  {
87  lock();
88 
89  T& result = _queue.front();
90 
91  return result;
92  }
template<class T, class LockType, typename StorageType = std::deque<T>>
void ACE_Based::LockedQueue< T, LockType, StorageType >::pop_front ( )
inline

Definition at line 124 of file LockedQueue.h.

125  {
126  ACE_GUARD (LockType, g, this->_lock);
127  _queue.pop_front();
128  }
LockType
template<class T, class LockType, typename StorageType = std::deque<T>>
void ACE_Based::LockedQueue< T, LockType, StorageType >::unlock ( )
inline

Member Data Documentation

template<class T, class LockType, typename StorageType = std::deque<T>>
volatile bool ACE_Based::LockedQueue< T, LockType, StorageType >::_canceled
private
template<class T, class LockType, typename StorageType = std::deque<T>>
LockType ACE_Based::LockedQueue< T, LockType, StorageType >::_lock
private

Definition at line 33 of file LockedQueue.h.

template<class T, class LockType, typename StorageType = std::deque<T>>
StorageType ACE_Based::LockedQueue< T, LockType, StorageType >::_queue
private

Definition at line 36 of file LockedQueue.h.


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