aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/test/simple_threading_service.h
blob: 9cb97dd452f44328b930546770f19c39e0ed825d (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
46
47
48
49
50
51
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include "simple_thread_service.h"
#include <vespa/searchcorespi/index/ithreadingservice.h>

namespace proton::test {

/**
 * Implementation of IThreadingService that overrides IThreadService::isCurrentThread() to true.
 * Can be used by unit tests that do not care about that functions are executed in the correct
 * thread.
 */
class SimpleThreadingService : public searchcorespi::index::IThreadingService
{
private:
    searchcorespi::index::IThreadingService &_service;
    SimpleThreadService _master;
    SimpleThreadService _index;

public:
    SimpleThreadingService(searchcorespi::index::IThreadingService &service)
        : _service(service),
          _master(_service.master()),
          _index(_service.index())
    {
    }
    virtual vespalib::Syncable &sync() {
        return _service.sync();
    }
    virtual searchcorespi::index::IThreadService &master() {
        return _master;
    }
    virtual searchcorespi::index::IThreadService &index() {
        return _index;
    }
    virtual search::ISequencedTaskExecutor &indexFieldInverter() {
        return _service.indexFieldInverter();
    }
    virtual search::ISequencedTaskExecutor &indexFieldWriter() {
        return _service.indexFieldWriter();
    }

    virtual search::ISequencedTaskExecutor &attributeFieldWriter() {
        return _service.attributeFieldWriter();
    }
};

}