aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/vespa/vespalib/util/threadstackexecutor.cpp
blob: 88ccde1ff386fcbf58f85441e92bc503ffb144b9 (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
43
44
45
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "threadstackexecutor.h"

namespace vespalib {

VESPA_THREAD_STACK_TAG(unnamed_nonblocking_executor);

bool
ThreadStackExecutor::acceptNewTask(unique_lock &, std::condition_variable &)
{
    return isRoomForNewTask();
}

void
ThreadStackExecutor::wakeup(unique_lock &, std::condition_variable &)
{
}

ThreadStackExecutor::ThreadStackExecutor(uint32_t threads)
    : ThreadStackExecutor(threads, unnamed_nonblocking_executor)
{ }

ThreadStackExecutor::ThreadStackExecutor(uint32_t threads, uint32_t taskLimit)
    : ThreadStackExecutorBase(taskLimit, unnamed_nonblocking_executor)
{
    start(threads);
}

ThreadStackExecutor::ThreadStackExecutor(uint32_t threads, init_fun_t init_function)
    : ThreadStackExecutor(threads, std::move(init_function), 0xffffffff)
{ }

ThreadStackExecutor::ThreadStackExecutor(uint32_t threads, init_fun_t init_function, uint32_t taskLimit)
    : ThreadStackExecutorBase(taskLimit, std::move(init_function))
{
    start(threads);
}

ThreadStackExecutor::~ThreadStackExecutor()
{
    cleanup();
}

} // namespace vespalib