summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2018-01-23 14:30:01 -0800
committerKonstantin Käfer <mail@kkaefer.com>2018-02-06 18:49:06 +0100
commit78f8fd88b434099a6bc16b19d59e20b851e168ef (patch)
tree85313822229125a1bb8fb9fe9b100c3f9006862f /include
parent3ef7dab1a8c59560ef04fb4bca34637e352f9a47 (diff)
downloadqtlocation-mapboxgl-78f8fd88b434099a6bc16b19d59e20b851e168ef.tar.gz
[core] factor out RunLoop::wake()
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/util/run_loop.hpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/include/mbgl/util/run_loop.hpp b/include/mbgl/util/run_loop.hpp
index acbea80273..ecb18c857b 100644
--- a/include/mbgl/util/run_loop.hpp
+++ b/include/mbgl/util/run_loop.hpp
@@ -76,16 +76,20 @@ private:
using Queue = std::queue<std::shared_ptr<WorkTask>>;
- void push(std::shared_ptr<WorkTask>);
+ // Wakes up the RunLoop so that it starts processing items in the queue.
+ void wake();
- void withMutex(std::function<void()>&& fn) {
+ // Adds a WorkTask to the queue, and wakes it up.
+ void push(std::shared_ptr<WorkTask> task) {
std::lock_guard<std::mutex> lock(mutex);
- fn();
+ queue.push(std::move(task));
+ wake();
}
void process() {
+ std::unique_lock<std::mutex> lock(mutex);
Queue queue_;
- withMutex([&] { queue_.swap(queue); });
+ lock.unlock();
while (!queue_.empty()) {
(*(queue_.front()))();