summaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/server/shared_threading_service.h
blob: 12686e4a3c567bad63f19109ce536f2909e8e0df (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include "i_shared_threading_service.h"
#include "shared_threading_service_config.h"
#include <vespa/vespalib/util/threadstackexecutor.h>
#include <vespa/vespalib/util/syncable.h>
#include <memory>

namespace proton {

/**
 * Class containing the thread executors that are shared across all document dbs.
 */
class SharedThreadingService : public ISharedThreadingService {
private:
    vespalib::ThreadStackExecutor _warmup;
    std::shared_ptr<vespalib::SyncableThreadExecutor> _shared;
    std::unique_ptr<vespalib::ISequencedTaskExecutor> _field_writer;

public:
    SharedThreadingService(const SharedThreadingServiceConfig& cfg);

    vespalib::SyncableThreadExecutor& warmup_raw() { return _warmup; }
    std::shared_ptr<vespalib::SyncableThreadExecutor> shared_raw() { return _shared; }

    vespalib::ThreadExecutor& warmup() override { return _warmup; }
    vespalib::ThreadExecutor& shared() override { return *_shared; }
    vespalib::ISequencedTaskExecutor* field_writer() override { return _field_writer.get(); }
};

}