Created
September 9, 2020 10:11
-
-
Save mazbox/ab66cd00d001b88dfb3cebb68c72f359 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "concurrentqueue.h" | |
moodycamel::ConcurrentQueue<function<void()>> audioThreadQueue(100); | |
moodycamel::ConcurrentQueue<function<void()>> uiThreadQueue(100); | |
void runOnAudioThread(function<void()> fn) { | |
audioThreadQueue.enqueue(fn); | |
} | |
void pollAudioThreadQueue() { | |
function<void()> fn; | |
while(audioThreadQueue.try_dequeue(fn)) { | |
fn(); | |
} | |
} | |
void runOnUIThread(function<void()> fn) { | |
uiThreadQueue.enqueue(fn); | |
} | |
void pollUIThreadQueue() { | |
function<void()> fn; | |
while(uiThreadQueue.try_dequeue(fn)) { | |
fn(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment