aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/vespa/storageframework/defaultimplementation/thread/threadpoolimpl.h
blob: d4c259fda2c67852fb9fb7d5a5c5c6a80d333b42 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/storageframework/generic/thread/threadpool.h>

namespace storage::framework {
    struct Clock;
}
namespace storage::framework::defaultimplementation {

class ThreadImpl;

struct ThreadPoolImpl final : public ThreadPool
{
    std::vector<ThreadImpl*>   _threads;
    mutable std::mutex         _threadVectorLock;
    Clock                    & _clock;
    bool                       _stopping;

public:
    ThreadPoolImpl(Clock&);
    ~ThreadPoolImpl() override;

    std::unique_ptr<Thread> startThread(Runnable&, vespalib::stringref id, vespalib::duration waitTime,
                                        vespalib::duration maxProcessTime, int ticksBeforeWait,
                                        std::optional<vespalib::CpuUsage::Category> cpu_category) override;
    void visitThreads(ThreadVisitor&) const override;
    void unregisterThread(ThreadImpl&);
    Clock& getClock() { return _clock; }
};

}