summaryrefslogtreecommitdiff
path: root/src/mbgl/util/worker.cpp
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <thiago@mapbox.com>2015-06-24 18:40:46 +0300
committerThiago Marcos P. Santos <thiago@mapbox.com>2015-06-25 16:26:21 +0300
commitbe4cb6786babca3368b10e2c1c1aaa9eb43e5663 (patch)
treeea3def9013e1666d92d35cff261e0f9bff16beba /src/mbgl/util/worker.cpp
parentb56c356de71a3edec76984ddf4202c92930bd17b (diff)
downloadqtlocation-mapboxgl-be4cb6786babca3368b10e2c1c1aaa9eb43e5663.tar.gz
Make the FileSource available from the ThreadContext
For now we set the FileSource for the Worker context but in the future after fixing #1664 we can assert() that FileSource are set only for the Map thread context.
Diffstat (limited to 'src/mbgl/util/worker.cpp')
-rw-r--r--src/mbgl/util/worker.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/mbgl/util/worker.cpp b/src/mbgl/util/worker.cpp
index 1806ba78ce..4c56057347 100644
--- a/src/mbgl/util/worker.cpp
+++ b/src/mbgl/util/worker.cpp
@@ -20,7 +20,16 @@ public:
Worker::Worker(std::size_t count) {
util::ThreadContext context = {"Worker", util::ThreadType::Worker, util::ThreadPriority::Low};
for (std::size_t i = 0; i < count; i++) {
- threads.emplace_back(std::make_unique<util::Thread<Impl>>(context));
+ std::unique_ptr<util::Thread<Impl>> worker(new util::Thread<Impl>(context));
+
+ // FIXME: Workers should not access the FileSource but it
+ // is currently needed because of GlyphsPBF. See #1664.
+ auto task = std::make_shared<WorkTask>([fs = util::ThreadContext::getFileSource()]{
+ util::ThreadContext::setFileSource(fs);
+ }, []{});
+
+ worker->invoke(&Worker::Impl::doWork, task);
+ threads.emplace_back(std::move(worker));
}
}