diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2017-10-10 15:35:00 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2018-02-06 18:49:06 +0100 |
commit | 3ef7dab1a8c59560ef04fb4bca34637e352f9a47 (patch) | |
tree | a3bf9dd6499f56b4468fb3370a9c2477f0a8da8f /include/mbgl/util | |
parent | d3deb6d71bdf837c3d82078630dbd11710a03d32 (diff) | |
download | qtlocation-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.hpp | 19 |
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; |