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.
This commit is contained in:
Thiago Marcos P. Santos
2015-06-24 18:40:46 +03:00
parent b56c356de7
commit be4cb6786b
13 changed files with 51 additions and 32 deletions

View File

@@ -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));
}
}