move worker to MapContext

This commit is contained in:
Konstantin Käfer
2015-03-24 10:59:31 +01:00
committed by John Firebaugh
parent 67fa80f5e9
commit f272d13dea
4 changed files with 13 additions and 11 deletions

View File

@@ -86,7 +86,6 @@ Map::~Map() {
// Explicitly reset all pointers.
style.reset();
workers.reset();
context.reset();
uv_run(env->loop, UV_RUN_DEFAULT);
@@ -94,11 +93,6 @@ Map::~Map() {
env->performCleanup();
}
Worker& Map::getWorker() {
assert(workers);
return *workers;
}
void Map::start(bool startPaused, Mode renderMode) {
assert(Environment::currentlyOn(ThreadType::Main));
assert(mode == Mode::None);
@@ -119,7 +113,7 @@ void Map::start(bool startPaused, Mode renderMode) {
// It's now safe to destroy/join the workers since there won't be any more callbacks that
// could dispatch to the worker pool.
workers.reset();
context->workers.reset();
terminating = true;
@@ -263,7 +257,7 @@ void Map::run() {
view.activate();
view.discard();
workers = util::make_unique<Worker>(env->loop, 4);
context->workers = util::make_unique<Worker>(env->loop, 4);
setup();
prepare();
@@ -744,7 +738,7 @@ void Map::updateTiles() {
assert(Environment::currentlyOn(ThreadType::Map));
if (!style) return;
for (const auto& source : style->sources) {
source->update(*data, getWorker(), style, *context->glyphAtlas, *context->glyphStore,
source->update(*data, context->getWorker(), style, *context->glyphAtlas, *context->glyphStore,
*context->spriteAtlas, getSprite(), *context->texturePool, [this]() {
assert(Environment::currentlyOn(ThreadType::Map));
triggerUpdate();