2 * Copyright (C) 2009 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <ace/Guard_T.h>
23 #include <ace/Thread_Mutex.h>
31 template <class T
, class LockType
, typename StorageType
=std::deque
<T
> >
35 //! Serialize access to the Queue
38 //! Storage backing the queue
42 volatile bool _canceled
;
46 //! Create a LockedQueue
47 LockedQueue() : _canceled(false) {}
49 //! Destroy a LockedQueue
50 virtual ~LockedQueue() { }
53 * @see Queue::add(const T& item)
55 void add(const T
& item
)
58 ACE_Guard
<LockType
> g(_lock
);
61 // throw Cancellation_Exception();
63 _queue
.push_back(item
);
73 ACE_Guard
<LockType
> g(_lock
);
75 ASSERT (!_queue
.empty() || !_canceled
);
76 // throw Cancellation_Exception();
78 T item
= _queue
.front();
87 ACE_Guard
<LockType
> g(_lock
);
89 ASSERT (!_queue
.empty());
90 // throw NoSuchElement_Exception();
92 return _queue
.front();
96 * @see Queue::cancel()
101 ACE_Guard
<LockType
> g(_lock
);
108 * @see Queue::isCanceled()
113 // Faster check since the queue will not become un-canceled
117 ACE_Guard
<LockType
> g(_lock
);
129 ACE_Guard
<LockType
> g(_lock
);
130 return _queue
.size();
137 ACE_Guard
<LockType
> g(_lock
);
138 return _queue
.empty();