6 #include <condition_variable> 16 std::condition_variable
fCond;
28 typedef std::function<void(const T &)>
callback;
35 std::unique_lock<std::mutex> lock(fMutex);
39 while (fList.empty() && fState==
kRun)
45 if (fState==
kStop && fList.empty())
48 const T &val = fList.front();
70 Queue(
const callback &f) : fSize(0), fState(
kIdle), fCallback(f)
81 const std::lock_guard<std::mutex> lock(fMutex);
92 const std::lock_guard<std::mutex> lock(fMutex);
104 const std::lock_guard<std::mutex> lock(fMutex);
117 const std::lock_guard<std::mutex> lock(fMutex);
134 const std::lock_guard<std::mutex> lock(fMutex);
138 fList.push_back(val);
146 #ifdef __GXX_EXPERIMENTAL_CXX0X__ 147 template<
typename... _Args>
148 bool emplace(_Args&&... __args)
150 const std::lock_guard<std::mutex> lock(fMutex);
154 fList.emplace_back(__args...);
162 bool post(T &&val) {
return emplace(std::move(val)); }
165 #ifdef __GXX_EXPERIMENTAL_CXX0X__ 166 bool move(std::list<T>&& x,
typename std::list<T>::iterator
i)
168 bool move(std::list<T>& x,
typename std::list<T>::iterator i)
171 const std::lock_guard<std::mutex> lock(fMutex);
175 fList.splice(fList.end(), x,
i);
183 #ifdef __GXX_EXPERIMENTAL_CXX0X__ 184 bool move(std::list<T>& x,
typename std::list<T>::iterator i) {
return move(std::move(x), i); }
bool move(std::list< T > &x, typename std::list< T >::iterator i)
std::condition_variable fCond
bool wait(bool abrt=false)
std::function< void(const T &)> callback
bool move(List &x, typename List::iterator i)