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>2017-10-10 15:35:00 +0200
commitb820a3031885e6b2df987dc71d1b4562b7ca25f2 (patch)
tree6899b6612e8feea689391e2b220cf8d758822d2d
parent98a47884f06a8f165a2c15a54f82b356c8ef23d8 (diff)
downloadqtlocation-mapboxgl-b820a3031885e6b2df987dc71d1b4562b7ca25f2.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;