diff options
author | Mike Morris <mikemorris@users.noreply.github.com> | 2016-10-12 17:28:22 -0400 |
---|---|---|
committer | Mike Morris <mikemorris@users.noreply.github.com> | 2016-10-20 14:37:36 -0400 |
commit | 817c26111a0d6650e7ebae73e46621626106d0a7 (patch) | |
tree | 60a5206f2f7658b06b214d9b7435a65a243d6e83 /include | |
parent | ab85fdb4524788ce7279e8ac362a0c1edbd5d5df (diff) | |
download | qtlocation-mapboxgl-817c26111a0d6650e7ebae73e46621626106d0a7.tar.gz |
[core] [node] pass thread pool impl to Map constructor
Updates mbgl::Map constructor usage everywhere
Adds NodeThreadPool implementation using AsyncQueue to call
Nan::AsyncQueueWorker from main thread
Diffstat (limited to 'include')
-rw-r--r-- | include/mbgl/map/map.hpp | 5 | ||||
-rw-r--r-- | include/mbgl/platform/default/thread_pool.hpp | 27 |
2 files changed, 30 insertions, 2 deletions
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index 914c2cd0b3..2831206d54 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -19,8 +19,9 @@ namespace mbgl { -class FileSource; class View; +class FileSource; +class Scheduler; class SpriteImage; struct CameraOptions; struct AnimationOptions; @@ -32,7 +33,7 @@ class Layer; class Map : private util::noncopyable { public: - explicit Map(View&, FileSource&, + explicit Map(View&, FileSource&, Scheduler&, MapMode mapMode = MapMode::Continuous, GLContextMode contextMode = GLContextMode::Unique, ConstrainMode constrainMode = ConstrainMode::HeightOnly, diff --git a/include/mbgl/platform/default/thread_pool.hpp b/include/mbgl/platform/default/thread_pool.hpp new file mode 100644 index 0000000000..a14d16d771 --- /dev/null +++ b/include/mbgl/platform/default/thread_pool.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include <mbgl/actor/scheduler.hpp> + +#include <condition_variable> +#include <mutex> +#include <queue> +#include <thread> + +namespace mbgl { + +class ThreadPool : public Scheduler { +public: + ThreadPool(std::size_t count); + ~ThreadPool() override; + + void schedule(std::weak_ptr<Mailbox>) override; + +private: + std::vector<std::thread> threads; + std::queue<std::weak_ptr<Mailbox>> queue; + std::mutex mutex; + std::condition_variable cv; + bool terminate { false }; +}; + +} // namespace mbgl |