[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.
This commit is contained in:
Konstantin Käfer
2017-10-10 15:35:00 +02:00
parent e6d6a231e8
commit 97005ccdfa

View File

@@ -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(); });
loop->schedule(mailbox);
}
void receive() {
std::unique_lock<std::mutex> lock(mutex);
auto mailbox = queue.front();
queue.pop();
lock.unlock();
Mailbox::maybeReceive(mailbox);
}
std::mutex mutex;
std::queue<std::weak_ptr<Mailbox>> queue;
std::thread thread;
std::unique_ptr<Actor<Object>> object;