blob: 9a03424f58033feb7922f4be82a975f240adb559 (
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.
/**
* \class storage::framework::ThreadPool
* \ingroup thread
*
* \brief A threadpool implementation usable by storage components.
*
* Using this threadpool interface, we can use a threadpool without depending
* on the actual implementation. Also, as information is provided of the
* threads, monitoring tools, like the deadlock detector can extract information
* about the threads.
*/
#pragma once
#include <atomic>
#include <vespa/vespalib/util/cpu_usage.h>
#include <optional>
#include <vector>
namespace storage::framework {
class Thread;
struct Runnable;
/** Interface used to access data for the existing threads. */
struct ThreadVisitor {
virtual ~ThreadVisitor() = default;
virtual void visitThread(const Thread& thread) = 0;
};
struct ThreadPool {
virtual ~ThreadPool() = default;
virtual std::unique_ptr<Thread>
startThread(Runnable&, vespalib::stringref id, vespalib::duration waitTime,
vespalib::duration maxProcessTime, int ticksBeforeWait,
std::optional<vespalib::CpuUsage::Category> cpu_category) = 0;
virtual void visitThreads(ThreadVisitor&) const = 0;
};
}
|