8 #include <condition_variable> 14 class condition_variable;
15 template<
class T>
class function<T>;
27 template<
class T,
class List=std::list<T>>
50 typedef std::function<bool(const T &)>
callback;
57 std::unique_lock<std::mutex> lock(fMutex);
65 while (fSize==allowed && fState==kRun)
72 if (fState==kStop && fList.empty())
88 const auto it = fList.begin();
101 if (fCallback && fCallback(*it))
122 Queue(
const callback &f,
bool startup=
true) : fSize(0), fState(
kIdle), fCallback(f)
140 #ifdef __MARS__ // Needed for the compilatio of the dictionary 153 const std::lock_guard<std::mutex> lock(fMutex);
164 const std::lock_guard<std::mutex> lock(fMutex);
176 const std::lock_guard<std::mutex> lock(fMutex);
189 const std::lock_guard<std::mutex> lock(fMutex);
190 if (fState==
kIdle || fState==kPrompt)
195 fState = abrt ? kAbort : kStop;
206 const std::lock_guard<std::mutex> lock(fMutex);
207 if (fState!=
kIdle || fSize>0)
216 const std::lock_guard<std::mutex> lock(fMutex);
226 return state ? enablePromptExecution() : disablePromptExecution();
232 const std::lock_guard<std::mutex> lock(fMutex);
234 return fCallback(val);
239 fList.push_back(val);
249 const std::lock_guard<std::mutex> lock(fMutex);
259 #ifdef __GXX_EXPERIMENTAL_CXX0X__ 260 template<
typename... _Args>
261 bool emplace(_Args&&... __args)
263 const std::lock_guard<std::mutex> lock(fMutex);
265 return fCallback(T(__args...));
270 fList.emplace_back(__args...);
278 bool post(T &&val) {
return emplace(std::move(val)); }
281 #ifdef __GXX_EXPERIMENTAL_CXX0X__ 282 bool move(List&& x,
typename List::iterator
i)
284 bool move(List& x,
typename List::iterator i)
287 const std::lock_guard<std::mutex> lock(fMutex);
291 fList.splice(fList.end(), x,
i);
299 #ifdef __GXX_EXPERIMENTAL_CXX0X__ 300 bool move(List& x,
typename List::iterator i) {
return move(std::move(x), i); }
315 return fSize < other.
fSize;
Queue(const Queue< T, List > &q)
std::function< bool(const T &)> callback
bool setPromptExecution(bool state)
bool disablePromptExecution()
std::condition_variable fCond
bool wait(bool abrt=false)
bool enablePromptExecution()
bool move(List &x, typename List::iterator i)
Queue(const callback &f, bool startup=true)
bool operator<(const Queue &other) const