From 3ef7dab1a8c59560ef04fb4bca34637e352f9a47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Tue, 10 Oct 2017 15:35:00 +0200 Subject: [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. --- include/mbgl/util/thread.hpp | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) (limited to 'include') 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) override { - { - std::lock_guard lock(mutex); - queue.push(mailbox); - } - - loop->invoke([this] { receive(); }); - } - - void receive() { - std::unique_lock lock(mutex); - - auto mailbox = queue.front(); - queue.pop(); - lock.unlock(); - - Mailbox::maybeReceive(mailbox); + loop->schedule(mailbox); } - std::mutex mutex; - std::queue> queue; std::thread thread; std::unique_ptr> object; -- cgit v1.2.1