summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-10-15 11:00:25 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-10-15 11:00:25 +0000
commit5a2a6986572689a23e94b5e819b375fc24e52adc (patch)
tree17b8bb9ff3621f6c4456c047f86cea95b5cd8087 /vespalib
parentc1a4a7762d032c2be2cf44ad34ab8bf402355d53 (diff)
monitor -> guard
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/util/threadstackexecutorbase.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/vespalib/src/vespa/vespalib/util/threadstackexecutorbase.cpp b/vespalib/src/vespa/vespalib/util/threadstackexecutorbase.cpp
index bde870c9cca..28ee2da2d8c 100644
--- a/vespalib/src/vespa/vespalib/util/threadstackexecutorbase.cpp
+++ b/vespalib/src/vespa/vespalib/util/threadstackexecutorbase.cpp
@@ -72,7 +72,7 @@ ThreadStackExecutorBase::unblock_threads(const unique_lock &)
void
ThreadStackExecutorBase::assignTask(TaggedTask task, Worker &worker)
{
- unique_lock monitor(worker.lock);
+ unique_lock guard(worker.lock);
worker.verify(/* idle: */ true);
worker.idle = false;
worker.task = std::move(task);
@@ -83,16 +83,16 @@ bool
ThreadStackExecutorBase::obtainTask(Worker &worker)
{
{
- unique_lock monitor(_lock);
+ unique_lock guard(_lock);
if (!worker.idle) {
assert(_taskCount != 0);
--_taskCount;
- wakeup(monitor, _cond);
+ wakeup(guard, _cond);
_barrier.completeEvent(worker.task.token);
worker.idle = true;
}
worker.verify(/* idle: */ true);
- unblock_threads(monitor);
+ unblock_threads(guard);
if (!_tasks.empty()) {
worker.task = std::move(_tasks.front());
worker.idle = false;
@@ -105,9 +105,9 @@ ThreadStackExecutorBase::obtainTask(Worker &worker)
_workers.push(&worker);
}
{
- unique_lock monitor(worker.lock);
+ unique_lock guard(worker.lock);
while (worker.idle) {
- worker.cond.wait(monitor);
+ worker.cond.wait(guard);
}
}
worker.idle = !worker.task.task;
@@ -139,6 +139,7 @@ ThreadStackExecutorBase::ThreadStackExecutorBase(uint32_t stackSize,
Runnable(),
_pool(std::make_unique<FastOS_ThreadPool>(stackSize)),
_lock(),
+ _cond(),
_stats(),
_executorCompletion(),
_tasks(),