summaryrefslogtreecommitdiff
path: root/include/mbgl/util
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-09-06 15:01:34 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-09-16 12:01:06 -0700
commit41bbd4e4f7d66465433e370ca024ab0239fcace3 (patch)
tree8fe15fa31d97aafeb175a808e431b437297af88b /include/mbgl/util
parent0bd66d40ddf9e75f860fe18e7c80de9c840f48ac (diff)
downloadqtlocation-mapboxgl-41bbd4e4f7d66465433e370ca024ab0239fcace3.tar.gz
[core] Use an actor model for tile worker concurrency
Diffstat (limited to 'include/mbgl/util')
-rw-r--r--include/mbgl/util/run_loop.hpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/include/mbgl/util/run_loop.hpp b/include/mbgl/util/run_loop.hpp
index 6559b72ef8..939531d6c3 100644
--- a/include/mbgl/util/run_loop.hpp
+++ b/include/mbgl/util/run_loop.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include <mbgl/actor/scheduler.hpp>
+#include <mbgl/actor/mailbox.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/util.hpp>
#include <mbgl/util/work_task.hpp>
@@ -16,7 +18,8 @@ namespace util {
typedef void * LOOP_HANDLE;
-class RunLoop : private util::noncopyable {
+class RunLoop : public Scheduler,
+ private util::noncopyable {
public:
enum class Type : uint8_t {
Default,
@@ -31,7 +34,7 @@ public:
};
RunLoop(Type type = Type::Default);
- ~RunLoop();
+ ~RunLoop() override;
static RunLoop* Get();
static LOOP_HANDLE getLoopHandle();
@@ -78,6 +81,14 @@ private:
void push(std::shared_ptr<WorkTask>);
+ void schedule(std::weak_ptr<Mailbox> mailbox) override {
+ invoke([mailbox] () {
+ if (auto locked = mailbox.lock()) {
+ locked->receive();
+ }
+ });
+ }
+
void withMutex(std::function<void()>&& fn) {
std::lock_guard<std::mutex> lock(mutex);
fn();