summaryrefslogtreecommitdiff
path: root/include/mbgl/util
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2017-10-10 15:35:00 +0200
committerKonstantin Käfer <mail@kkaefer.com>2018-02-06 18:49:06 +0100
commit3ef7dab1a8c59560ef04fb4bca34637e352f9a47 (patch)
treea3bf9dd6499f56b4468fb3370a9c2477f0a8da8f /include/mbgl/util
parentd3deb6d71bdf837c3d82078630dbd11710a03d32 (diff)
downloadqtlocation-mapboxgl-3ef7dab1a8c59560ef04fb4bca34637e352f9a47.tar.gz
[core] use the RunLoop's schedule call directly
RunLoop already has a queue, and has the ability to schedule weak mailboxes, so we can remove the duplicate code.
Diffstat (limited to 'include/mbgl/util')
-rw-r--r--include/mbgl/util/thread.hpp19
1 files changed, 1 insertions, 18 deletions
diff --git a/include/mbgl/util/thread.hpp b/include/mbgl/util/thread.hpp
index 672eebf6db..e3bd18143d 100644
--- a/include/mbgl/util/thread.hpp
+++ b/include/mbgl/util/thread.hpp
@@ -128,26 +128,9 @@ private:
MBGL_STORE_THREAD(tid);
void schedule(std::weak_ptr<Mailbox> mailbox) override {
- {
- std::lock_guard<std::mutex> lock(mutex);
- queue.push(mailbox);
- }
-
- loop->invoke([this] { receive(); });
- }
-
- void receive() {
- std::unique_lock<std::mutex> lock(mutex);
-
- auto mailbox = queue.front();
- queue.pop();
- lock.unlock();
-
- Mailbox::maybeReceive(mailbox);
+ loop->schedule(mailbox);
}
- std::mutex mutex;
- std::queue<std::weak_ptr<Mailbox>> queue;
std::thread thread;
std::unique_ptr<Actor<Object>> object;