21 #include <condition_variable>
34 mForegroundQueue(&mQueueAlpha),
35 mBackgroundQueue(&mQueueBeta)
41 std::unique_lock<std::mutex> fgGuard(mForegroundMutex);
42 std::unique_lock<std::mutex> bgGuard(mBackgroundMutex);
45 std::queue<T>().swap(*mForegroundQueue);
47 auto* swap = mBackgroundQueue;
48 mBackgroundQueue = mForegroundQueue;
49 mForegroundQueue = swap;
55 std::unique_lock<std::mutex> guard(mBackgroundMutex);
56 mBackgroundQueue->push(item);
63 std::unique_lock<std::mutex> guard(mForegroundMutex);
64 return mForegroundQueue->front();
69 std::unique_lock<std::mutex> guard(mForegroundMutex);
70 return mForegroundQueue->front();
76 std::unique_lock<std::mutex> guard(mForegroundMutex);
77 mForegroundQueue->pop();
83 std::unique_lock<std::mutex> guard(mForegroundMutex);
84 return mForegroundQueue->empty();
90 std::unique_lock<std::mutex> guard(mForegroundMutex);
91 std::unique_lock<std::mutex> bgGuard(mBackgroundMutex);
92 return mForegroundQueue->empty() && mBackgroundQueue->empty();
98 std::unique_lock<std::mutex> guard(mForegroundMutex);
99 return mForegroundQueue->size();
105 std::unique_lock<std::mutex> fgGuard(mForegroundMutex);
106 std::unique_lock<std::mutex> bgGuard(mBackgroundMutex);
107 std::queue<T>().swap(*mForegroundQueue);
108 std::queue<T>().swap(*mBackgroundQueue);
113 std::queue<T> mQueueAlpha;
114 std::queue<T> mQueueBeta;
117 std::queue<T>* mForegroundQueue;
118 std::queue<T>* mBackgroundQueue;
120 mutable std::mutex mForegroundMutex;
121 mutable std::mutex mBackgroundMutex;