Skip to content

Commit

Permalink
Fix threading bug
Browse files Browse the repository at this point in the history
  • Loading branch information
myrsloik committed Jul 24, 2021
1 parent 5e88f13 commit 187221f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/core/vsthreadpool.cpp
Expand Up @@ -107,13 +107,12 @@ void VSThreadPool::runTasks(std::atomic<bool> &stop) {
}

PVSFrameContext mainContextRef = std::move(*iter);
tasks.erase(iter);
allContexts.erase(frameContext->key);

if (frameContext->external)
returnFrame(frameContext, f);

allContexts.erase(frameContext->key);
tasks.erase(iter);

if (needsSort)
tasks.sort(taskCmp);

Expand Down Expand Up @@ -293,6 +292,7 @@ size_t VSThreadPool::setThreadCount(size_t threads) {
}

void VSThreadPool::queueTask(const PVSFrameContext &ctx) {
assert(ctx);
tasks.push_front(ctx);
wakeThread();
}
Expand All @@ -318,6 +318,7 @@ void VSThreadPool::startExternal(const PVSFrameContext &context) {
assert(context);
std::lock_guard<std::mutex> l(taskLock);
context->reqOrder = ++reqCounter;
assert(context);
tasks.push_back(context); // external requests can't be combined so just add to queue
wakeThread();
}
Expand Down

0 comments on commit 187221f

Please sign in to comment.