blob: 3e5ce6e7a53f0b070bf754484d87f0acee22c9ed (
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "transport_helper.h"
#include <vespa/fnet/transport.h>
#include <vespa/searchcore/proton/server/executorthreadingservice.h>
#include <vespa/vespalib/util/sequencedtaskexecutor.h>
#include <vespa/vespalib/util/size_literals.h>
#include <vespa/vespalib/util/testclock.h>
#include <vespa/vespalib/util/threadstackexecutor.h>
namespace proton {
Transport::Transport()
: _transport(std::make_unique<FNET_Transport>()),
_clock(std::make_unique<vespalib::TestClock>())
{
_transport->Start();
}
Transport::~Transport() {
shutdown();
}
const vespalib::Clock &
Transport::clock() const {
return _clock->clock();
}
void
Transport::shutdown() {
_transport->ShutDown(true);
}
VESPA_THREAD_STACK_TAG(proton_transport_and_executor_field_writer)
TransportAndExecutor::TransportAndExecutor(size_t num_threads)
: Transport(),
_sharedExecutor(std::make_unique<vespalib::ThreadStackExecutor>(num_threads)),
_field_writer(vespalib::SequencedTaskExecutor::create(proton_transport_and_executor_field_writer, num_threads))
{}
TransportAndExecutor::~TransportAndExecutor() = default;
void
TransportAndExecutor::shutdown() {
Transport::shutdown();
}
TransportAndExecutorService::TransportAndExecutorService(size_t num_threads)
: TransportAndExecutor(num_threads),
_writeService(std::make_unique<ExecutorThreadingService>(shared(), transport(), clock(), field_writer()))
{}
TransportAndExecutorService::~TransportAndExecutorService() = default;
searchcorespi::index::IThreadingService &
TransportAndExecutorService::write() {
return *_writeService;
}
void TransportAndExecutorService::shutdown() {
_writeService->shutdown();
TransportAndExecutor::shutdown();
}
}
|