blob: 2328702e1471f7a26ba5aa19808fa99153565205 (
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "executor_thread_service.h"
#include <vespa/searchcorespi/index/ithreadingservice.h>
#include <vespa/vespalib/util/blockingthreadstackexecutor.h>
#include <vespa/vespalib/util/threadstackexecutor.h>
#include <vespa/searchlib/common/sequencedtaskexecutor.h>
namespace proton {
/**
* Implementation of IThreadingService using 2 underlying thread stack executors
* with 1 thread each.
*/
class ExecutorThreadingService : public searchcorespi::index::IThreadingService
{
private:
vespalib::ThreadStackExecutor _masterExecutor;
vespalib::BlockingThreadStackExecutor _indexExecutor;
vespalib::ThreadStackExecutor _summaryExecutor;
ExecutorThreadService _masterService;
ExecutorThreadService _indexService;
ExecutorThreadService _summaryService;
search::SequencedTaskExecutor _indexFieldInverter;
search::SequencedTaskExecutor _indexFieldWriter;
search::SequencedTaskExecutor _attributeFieldWriter;
public:
/**
* Constructor.
*
* @stackSize The size of the stack of the underlying executors.
* @taskLimit The task limit for the index executor.
*/
ExecutorThreadingService(uint32_t threads = 1,
uint32_t stackSize = 128 * 1024,
uint32_t taskLimit = 1000);
~ExecutorThreadingService();
/**
* Implements vespalib::Syncable
*/
virtual vespalib::Syncable &sync() override;
void shutdown();
void setTaskLimit(uint32_t taskLimit);
void setUnboundTaskLimit();
// Expose the underlying executors for stats fetching and testing.
vespalib::ThreadStackExecutorBase &getMasterExecutor() {
return _masterExecutor;
}
vespalib::ThreadStackExecutorBase &getIndexExecutor() {
return _indexExecutor;
}
vespalib::ThreadStackExecutorBase &getSummaryExecutor() {
return _summaryExecutor;
}
/**
* Implements IThreadingService
*/
virtual searchcorespi::index::IThreadService &master() override {
return _masterService;
}
virtual searchcorespi::index::IThreadService &index() override {
return _indexService;
}
virtual searchcorespi::index::IThreadService &summary() override {
return _summaryService;
}
virtual search::ISequencedTaskExecutor &indexFieldInverter() override {
return _indexFieldInverter;
}
virtual search::ISequencedTaskExecutor &indexFieldWriter() override {
return _indexFieldWriter;
}
virtual search::ISequencedTaskExecutor &attributeFieldWriter() override {
return _attributeFieldWriter;
}
};
} // namespace proton
|