35 #ifndef _TclThreadList_H__ 36 #define _TclThreadList_H__ 42 #include <boost/thread/condition_variable.hpp> 43 #include <boost/thread/shared_mutex.hpp> 44 #include <boost/thread/locks.hpp> 57 template <
class InputIterator>
void insert(
typename std::list<T>::iterator position, InputIterator begin, InputIterator end);
67 bool is_in(
const T& value)
const;
73 {
return this->
list_; }
78 inline const std::list<T>&
getList()
const 79 {
return this->
list_; }
99 boost::unique_lock<boost::shared_mutex> lock(this->
mutex_);
100 this->
list_.push_front(value);
111 boost::unique_lock<boost::shared_mutex> lock(this->
mutex_);
112 this->
list_.push_back(value);
121 template <
class InputIterator>
void TclThreadList<T>::insert(
typename std::list<T>::iterator position, InputIterator begin, InputIterator end)
123 boost::unique_lock<boost::shared_mutex> lock(this->
mutex_);
124 this->
list_.insert(position, begin, end);
136 boost::unique_lock<boost::shared_mutex> lock(this->
mutex_);
138 while (this->
list_.empty())
141 *value = this->
list_.front();
142 this->
list_.pop_front();
152 boost::unique_lock<boost::shared_mutex> lock(this->
mutex_);
154 while (this->
list_.empty())
157 *value = this->
list_.back();
158 this->
list_.pop_back();
171 boost::upgrade_lock<boost::shared_mutex> lock(this->
mutex_);
173 if (this->
list_.empty())
181 boost::upgrade_to_unique_lock<boost::shared_mutex> unique_lock(lock);
182 *value = this->
list_.front();
183 this->
list_.pop_front();
198 boost::upgrade_lock<boost::shared_mutex> lock(this->
mutex_);
200 if (this->
list_.empty())
208 boost::upgrade_to_unique_lock<boost::shared_mutex> unique_lock(lock);
209 *value = this->
list_.back();
210 this->
list_.pop_back();
221 boost::unique_lock<boost::shared_mutex> lock(this->
mutex_);
235 boost::shared_lock<boost::shared_mutex> lock(this->
mutex_);
236 return this->
list_.size();
249 boost::shared_lock<boost::shared_mutex> lock(this->
mutex_);
250 return this->
list_.empty();
262 boost::shared_lock<boost::shared_mutex> lock(this->
mutex_);
264 for (
const T& element : this->
list_)
265 if (element == value)
const std::list< T > & getList() const
Returns a reference to the list.
Definition: TclThreadList.h:78
Shared library macros, enums, constants and forward declarations for the core library ...
bool try_pop_front(T *value)
Pops and returns the front element if there's at least one element in the list.
Definition: TclThreadList.h:169
std::list< T > list_
A standard list for type T.
Definition: TclThreadList.h:88
boost::condition_variable_any condition_
A condition variable to wake threads waiting for the mutex to become ready.
Definition: TclThreadList.h:90
bool is_in(const T &value) const
Returns true if a given element is in the list, false otherwise.
Definition: TclThreadList.h:260
void clear()
Clears the list.
Definition: TclThreadList.h:219
boost::shared_mutex mutex_
A mutex to grant exclusive access to the list.
Definition: TclThreadList.h:89
A thread-safe implementation of a message queue, used by TclThreadManager.
Definition: TclThreadList.h:52
void wait_and_pop_back(T *value)
Waits until the list contains at least one element and then pops and returns the back element...
Definition: TclThreadList.h:150
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
boost::shared_mutex & getMutex() const
Returns a reference to the mutex which might be useful if you want to iterate through the list (see g...
Definition: TclThreadList.h:84
void push_back(const T &value)
Pushes a new element to the back of the list.
Definition: TclThreadList.h:109
Definition: InputPrereqs.h:78
void insert(typename std::list< T >::iterator position, InputIterator begin, InputIterator end)
Inserts new elements into the list.
Definition: TclThreadList.h:121
std::list< T > & getList()
Returns a reference to the list.
Definition: TclThreadList.h:72
bool empty() const
Returns true if the list is empty, false otherwise.
Definition: TclThreadList.h:247
void push_front(const T &value)
Pushes a new element to the front of the list.
Definition: TclThreadList.h:97
size_t size() const
Returns the size of the list.
Definition: TclThreadList.h:233
void wait_and_pop_front(T *value)
Waits until the list contains at least one element and then pops and returns the front element...
Definition: TclThreadList.h:134
bool try_pop_back(T *value)
Pops and returns the back element if there's at least one element in the list.
Definition: TclThreadList.h:196