summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-11-27 23:41:30 +0200
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-11-28 14:34:52 +0200
commitb5794730b5cfba58be0aa63070718cde662bb538 (patch)
treeed56f988fda080dfff63040ebee10391468a9708 /include
parent316f1d0ad19459c9494b874a05707b45cb14db72 (diff)
downloadqtlocation-mapboxgl-b5794730b5cfba58be0aa63070718cde662bb538.tar.gz
[core] Introduce Scheduler::GetSequenced() API
The newly introduced `Scheduler::GetSequenced()` returns sequenced schedulers from the cache limited to 10 instances, preventing from spawning too many threads.
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/actor/scheduler.hpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/mbgl/actor/scheduler.hpp b/include/mbgl/actor/scheduler.hpp
index 1115328797..04cbc389e5 100644
--- a/include/mbgl/actor/scheduler.hpp
+++ b/include/mbgl/actor/scheduler.hpp
@@ -69,8 +69,21 @@ public:
// Get the scheduler for asynchronous tasks. This method
// will lazily initialize a shared worker pool when ran
// from the first time.
+ // The scheduled tasks might run in parallel on different
+ // threads.
+ // TODO : Rename to GetPool()
static std::shared_ptr<Scheduler> GetBackground();
+ // Get the *sequenced* scheduler for asynchronous tasks.
+ // Unlike the method above, the returned scheduler
+ // (once stored) represents a single thread, thus each
+ // newly scheduled task is guarantied to run after the
+ // previously scheduled one.
+ //
+ // Sequenced scheduler can be used for running tasks
+ // on the same thread-unsafe object.
+ static std::shared_ptr<Scheduler> GetSequenced();
+
protected:
template <typename TaskFn, typename ReplyFn>
void scheduleAndReplyValue(const TaskFn& task,