blob: 1a0de8c04d0d6cd022780b6d9e01721f85b543df (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "blockingthreadstackexecutor.h"
namespace vespalib {
VESPA_THREAD_STACK_TAG(unnamed_blocking_executor);
bool
BlockingThreadStackExecutor::acceptNewTask(unique_lock & guard, std::condition_variable & cond)
{
while (!closed() && !isRoomForNewTask() && !owns_this_thread()) {
cond.wait(guard);
}
return (!closed());
}
void
BlockingThreadStackExecutor::wakeup(unique_lock &, std::condition_variable & cond)
{
cond.notify_all();
}
BlockingThreadStackExecutor::BlockingThreadStackExecutor(uint32_t threads, uint32_t taskLimit)
: ThreadStackExecutorBase(taskLimit, unnamed_blocking_executor)
{
start(threads);
}
BlockingThreadStackExecutor::BlockingThreadStackExecutor(uint32_t threads, uint32_t taskLimit,
init_fun_t init_function)
: ThreadStackExecutorBase(taskLimit, std::move(init_function))
{
start(threads);
}
BlockingThreadStackExecutor::~BlockingThreadStackExecutor()
{
cleanup();
}
} // namespace vespalib
|