31 static void Combine(T & a_existing,
const T & a_new)
42 template <
class ItemType,
class Funcs = cQueueFuncs<ItemType> >
60 m_Contents.push_back(a_Item);
70 for (iterator itr = m_Contents.begin(); itr != m_Contents.end(); ++itr)
74 Funcs::Combine(*itr, a_Item);
78 m_Contents.push_back(a_Item);
88 if (m_Contents.empty())
92 item = m_Contents.front();
93 m_Contents.pop_front();
103 while (m_Contents.empty())
108 ItemType item = m_Contents.front();
109 m_Contents.pop_front();
119 while (!m_Contents.empty())
131 while (!m_Contents.empty())
133 Funcs::Delete(m_Contents.front());
134 m_Contents.pop_front();
144 return m_Contents.size();
153 for (iterator itr = m_Contents.begin(); itr != m_Contents.end(); ++itr)
155 if ((*itr) == a_Item)
157 m_Contents.erase(itr);
167 template <
class Predicate>
171 for (
auto itr = m_Contents.begin(); itr != m_Contents.end();)
173 if (a_Predicate(*itr))
177 m_Contents.erase(itr);
void RemoveIf(Predicate a_Predicate)
Removes all items for which the predicate returns true.
static void Combine(T &a_existing, const T &a_new)
Called when an Item is inserted with EnqueueItemIfNotPresent and there is another equal value already...
QueueType::iterator iterator
std::list< ItemType > QueueType
bool Remove(ItemType a_Item)
Removes the item from the queue.
cEvent m_evtAdded
Event that is signalled when an item is added.
This empty struct allows for the callback functions to be inlined.
void Clear(void)
Removes all Items from the Queue, calling Delete on each of them.
void EnqueueItem(ItemType a_Item)
Enqueues an item to the queue, may block if other threads are accessing the queue.
ItemType DequeueItem(void)
Dequeues an item from the queue, blocking until an item is available.
size_t Size(void)
Returns the size at time of being called.
QueueType m_Contents
The contents of the queue.
Temporary RAII unlock for a cCSLock.
cCriticalSection m_CS
Mutex that protects access to the queue contents.
void BlockTillEmpty(void)
Blocks until the queue is empty.
RAII for cCriticalSection - locks the CS on creation, unlocks on destruction.
bool TryDequeueItem(ItemType &item)
Dequeues an item from the queue if any are present.
void EnqueueItemIfNotPresent(ItemType a_Item)
Enqueues an item in the queue if not already present (as determined by operator ==).
cEvent m_evtRemoved
Event that is signalled when an item is removed (both dequeued or erased)
static void Delete(T)
Called when an Item is deleted from the queue without being returned.