diff options
author | m-stephen <truestyle2005@163.com> | 2019-11-01 10:27:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-01 10:27:03 +0800 |
commit | 9427c04bc709c39f7e083b6d1597aaf33af8c302 (patch) | |
tree | 224fa2bffbc6a81b447c76b98e4c13a51baadc29 /src/mbgl/actor/mailbox.cpp | |
parent | fc2c02bbc6abaef52077fe5e9e78f772e6009967 (diff) | |
parent | 5b38cfee18800cbb3c6a3186882744592662c3d6 (diff) | |
download | qtlocation-mapboxgl-upstream/stephen-improve-accuracy-for-camera.tar.gz |
Merge branch 'master' into stephen-improve-accuracy-for-cameraupstream/stephen-improve-accuracy-for-camera
Diffstat (limited to 'src/mbgl/actor/mailbox.cpp')
-rw-r--r-- | src/mbgl/actor/mailbox.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/mbgl/actor/mailbox.cpp b/src/mbgl/actor/mailbox.cpp index dfe0520790..070e14bdb0 100644 --- a/src/mbgl/actor/mailbox.cpp +++ b/src/mbgl/actor/mailbox.cpp @@ -27,7 +27,7 @@ void Mailbox::open(Scheduler& scheduler_) { } if (!queue.empty()) { - (*scheduler)->schedule(shared_from_this()); + (*scheduler)->schedule(makeClosure(shared_from_this())); } } @@ -57,7 +57,7 @@ void Mailbox::push(std::unique_ptr<Message> message) { bool wasEmpty = queue.empty(); queue.push(std::move(message)); if (wasEmpty && scheduler) { - (*scheduler)->schedule(shared_from_this()); + (*scheduler)->schedule(makeClosure(shared_from_this())); } } @@ -84,14 +84,20 @@ void Mailbox::receive() { (*message)(); if (!wasEmpty) { - (*scheduler)->schedule(shared_from_this()); + (*scheduler)->schedule(makeClosure(shared_from_this())); } } +// static void Mailbox::maybeReceive(std::weak_ptr<Mailbox> mailbox) { if (auto locked = mailbox.lock()) { locked->receive(); } } +// static +std::function<void()> Mailbox::makeClosure(std::weak_ptr<Mailbox> mailbox) { + return [mailbox]() { maybeReceive(mailbox); }; +} + } // namespace mbgl |