Toolbox
snapshot
The Reactive C++ Toolbox
Loading...
Searching...
No Matches
toolbox
io
Runner.hpp
Go to the documentation of this file.
1
// The Reactive C++ Toolbox.
2
// Copyright (C) 2013-2019 Swirly Cloud Limited
3
// Copyright (C) 2022 Reactive Markets Limited
4
//
5
// Licensed under the Apache License, Version 2.0 (the "License");
6
// you may not use this file except in compliance with the License.
7
// You may obtain a copy of the License at
8
//
9
// http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing, software
12
// distributed under the License is distributed on an "AS IS" BASIS,
13
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
// See the License for the specific language governing permissions and
15
// limitations under the License.
16
17
#ifndef TOOLBOX_IO_RUNNER_HPP
18
#define TOOLBOX_IO_RUNNER_HPP
19
20
#include <
toolbox/hdr/Histogram.hpp
>
21
#include <
toolbox/sys/Thread.hpp
>
22
#include <
toolbox/sys/Time.hpp
>
23
24
#include <functional>
25
#include <thread>
26
27
namespace
toolbox
{
28
inline
namespace
io {
29
class
Reactor;
30
31
using
HistogramPtr
= std::unique_ptr<Histogram>;
32
34
using
MetricCallbackFunction
35
= std::function<
void
(
CyclTime
now,
HistogramPtr
&&
time_hist
,
HistogramPtr
&&
work_hist
)>;
37
using
LoopCallbackFunction
= std::function<
void
(
CyclTime
now)>;
38
39
class
TOOLBOX_API
ReactorRunner
{
40
public
:
51
ReactorRunner
(
Reactor
& r,
long
busy_cycles,
ThreadConfig
config);
52
64
ReactorRunner
(
Reactor
& r,
long
busy_cycles,
ThreadConfig
config,
65
MetricCallbackFunction
metric_cb);
66
79
ReactorRunner
(
Reactor
& r,
long
busy_cycles,
ThreadConfig
config,
80
MetricCallbackFunction
metric_cb,
LoopCallbackFunction
loop_cb);
81
82
~ReactorRunner
();
83
84
// Copy.
85
ReactorRunner
(
const
ReactorRunner
&) =
delete
;
86
ReactorRunner
&
operator=
(
const
ReactorRunner
&) =
delete
;
87
88
// Move.
89
ReactorRunner
(
ReactorRunner
&&) =
delete
;
90
ReactorRunner
&
operator=
(
ReactorRunner
&&) =
delete
;
91
92
private
:
93
Reactor
& reactor_;
94
std::atomic<bool> stop_{
false
};
95
std::thread thread_;
96
};
97
98
}
// namespace io
99
}
// namespace toolbox
100
101
#endif
// TOOLBOX_IO_RUNNER_HPP
TOOLBOX_API
#define TOOLBOX_API
Definition
Config.h:39
Histogram.hpp
Thread.hpp
Time.hpp
toolbox::io::ReactorRunner
Definition
Runner.hpp:39
toolbox::io::ReactorRunner::operator=
ReactorRunner & operator=(const ReactorRunner &)=delete
toolbox::io::ReactorRunner::ReactorRunner
ReactorRunner(ReactorRunner &&)=delete
toolbox::io::ReactorRunner::operator=
ReactorRunner & operator=(ReactorRunner &&)=delete
toolbox::io::ReactorRunner::ReactorRunner
ReactorRunner(const ReactorRunner &)=delete
toolbox::io::Reactor
Definition
Reactor.hpp:34
toolbox::CyclTime
Definition
Time.hpp:126
toolbox::io::LoopCallbackFunction
std::function< void(CyclTime now)> LoopCallbackFunction
LoopCallbackFunction called at end of each Reactor loop, indicating micros taken and work done.
Definition
Runner.hpp:37
toolbox::io::MetricCallbackFunction
std::function< void(CyclTime now, HistogramPtr &&time_hist, HistogramPtr &&work_hist)> MetricCallbackFunction
MetricCallbackFunction implementer is responsible for deleting the Histogram.
Definition
Runner.hpp:35
toolbox::io::HistogramPtr
std::unique_ptr< Histogram > HistogramPtr
Definition
Runner.hpp:31
toolbox::util::bind
constexpr auto bind() noexcept
Definition
Slot.hpp:92
toolbox
Definition
Benchmark.cpp:26
toolbox::ThreadConfig
ThreadConfig holds the thread attributes.
Definition
Thread.hpp:29
Generated by
1.9.8