Chops Net IP
Loading...
Searching...
No Matches
output_queue_stats.hpp
Go to the documentation of this file.
1
17#ifndef OUTPUT_QUEUE_STATS_HPP_INCLUDED
18#define OUTPUT_QUEUE_STATS_HPP_INCLUDED
19
20#include <cstddef> // std::size_t
21#include <numeric> // std::accumulate
22
25
26namespace chops {
27namespace net {
28
47template <typename Iter>
49 return std::accumulate(beg, end, output_queue_stats(),
50 [] (const output_queue_stats& sum, const auto& io) {
51 auto rhs = io.get_output_queue_stats();
52 return rhs ? output_queue_stats { sum.output_queue_size + rhs->output_queue_size,
53 sum.bytes_in_output_queue + rhs->bytes_in_output_queue } :
54 sum;
55 }
56 );
57}
58
99template <typename Iter, typename Cond>
100void accumulate_output_queue_stats_until(Iter beg, Iter end, Cond&& cond) {
101 while (!cond(accumulate_output_queue_stats(beg, end))) {
102 ; // no-op, tight loop
103 }
104}
105
121template <typename IOT, typename Iter>
123 return std::accumulate(beg, end, output_queue_stats(),
124 [] (const output_queue_stats& sum, const auto& ne) {
126 ne.visit_io_output([&st] (basic_io_output<IOT> io) {
127 auto r = io.get_output_queue_stats();
128 if (r) {
129 st.output_queue_size += r->output_queue_size;
130 st.bytes_in_output_queue += r->bytes_in_output_queue;
131 }
132 }
133 );
134 return output_queue_stats {sum.output_queue_size + st.output_queue_size,
135 sum.bytes_in_output_queue + st.bytes_in_output_queue};
136 }
137 );
138}
139
156template <typename IOT, typename Iter, typename Cond>
157void accumulate_net_entity_output_queue_stats_until(Iter beg, Iter end, Cond&& cond) {
158 while (!cond(accumulate_net_entity_output_queue_stats<IOT>(beg, end))) {
159 ; // no-op, tight loop
160 }
161}
162
163} // end net namespace
164} // end chops namespace
165
166#endif
167
basic_io_output class template, providing send and get_output_queue_stats methods.
The basic_io_output class template provides methods for sending data to an associated network IO hand...
Definition basic_io_output.hpp:57
auto get_output_queue_stats() const -> nonstd::expected< output_queue_stats, std::error_code >
Return output queue statistics, allowing application monitoring of output queue sizes.
Definition basic_io_output.hpp:101
void accumulate_net_entity_output_queue_stats_until(Iter beg, Iter end, Cond &&cond)
Accumulate output_queue_stats on a sequence of net_entity objects until a condition is satisfied.
Definition output_queue_stats.hpp:157
void accumulate_output_queue_stats_until(Iter beg, Iter end, Cond &&cond)
Accumulate output_queue_stats on a sequence of basic_io_output objects until a condition is satisfied...
Definition output_queue_stats.hpp:100
output_queue_stats accumulate_net_entity_output_queue_stats(Iter beg, Iter end)
Accumulate output_queue_stats given a sequence of net_entity objects, using the visit_io_output metho...
Definition output_queue_stats.hpp:122
output_queue_stats accumulate_output_queue_stats(Iter beg, Iter end)
Accumulate output_queue_stats given a sequence of basic_io_output objects.
Definition output_queue_stats.hpp:48
Structures containing statistics gathered on internal queues.
output_queue_stats provides information on the internal output queue.
Definition queue_stats.hpp:29