19#include <AUI/Thread/AMutex.h>
20#include <AUI/Common/ADeque.h>
28template<
typename Mutex =
AMutex,
typename... Args>
31 using Message = std::function<void(Args...)>;
37 std::unique_lock lock(mSync);
38 mMessages << std::move(message);
46 if (mMessages.empty()) {
49 std::unique_lock lock(mSync);
50 while (!mMessages.empty()) {
52 auto queue = std::move(mMessages);
54 for (
auto &message: queue) {
60 if (mMessages.empty()) {
69 Mutex& sync() noexcept {
79 const Mutex& sync() const noexcept {
A std::deque with AUI extensions.
Definition: ADeque.h:27
Universal thread-safe message (callback) queue implementation.
Definition: AMessageQueue.h:29
void enqueue(Message message)
Add message to the queue to process in processMessages().
Definition: AMessageQueue.h:36
void processMessages(Args... args)
Process messages submitted by enqueue method.
Definition: AMessageQueue.h:44
API_AUI_CORE const ACommandLineArgs & args() noexcept
Definition: OSAndroid.cpp:29
Basic syscall-based synchronization primitive.
Definition: AMutex.h:33