summaryrefslogtreecommitdiff
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-07 18:21:58 +0100
commit97005ccdfa6641a3d33fbe046b5c7dc5fdb72999 (patch)
treebe144f5c54676532e58d9181f2280b2054747c1d
parente6d6a231e861f3e1e1f8c193bb17196dec9d05eb (diff)
downloadqtlocation-mapboxgl-97005ccdfa6641a3d33fbe046b5c7dc5fdb72999.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.
-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;