3#include <ossia/detail/flat_map.hpp>
4#include <ossia/network/base/message_queue.hpp>
5#include <ossia/network/base/parameter_data.hpp>
6#include <ossia/network/base/protocol.hpp>
8#include <readerwriterqueue.h>
20 using clock = std::chrono::high_resolution_clock;
21 using duration = clock::duration;
22 rate_limiting_protocol(duration d, std::unique_ptr<protocol_base> arg);
23 ~rate_limiting_protocol()
override;
25 void set_duration(duration d);
30 bool push_raw(
const full_parameter_data&)
override;
34 void set_logger(
const network_logger& l)
override;
35 const network_logger& get_logger() const noexcept override;
38 void set_device(
ossia::net::device_base& dev) override;
40 void parameter_removed(const
ossia::net::parameter_base& b);
42 rate_limiting_protocol() = delete;
43 rate_limiting_protocol(const rate_limiting_protocol&) = delete;
44 rate_limiting_protocol(rate_limiting_protocol&&) = delete;
45 rate_limiting_protocol& operator=(const rate_limiting_protocol&) = delete;
46 rate_limiting_protocol& operator=(rate_limiting_protocol&&) = delete;
48 friend struct rate_limiter;
50 std::atomic<duration> m_duration{};
51 std::unique_ptr<ossia::net::protocol_base> m_protocol;
54 std::atomic_bool m_running{
true};
57 clock::time_point m_lastTime;
58 using map_t = ossia::flat_map<
62 map_t m_threadMessages;
63 std::mutex m_msgMutex;
66template <
typename Protocol,
typename... Args>
67auto limit_output_rate(std::chrono::milliseconds ms, Args&&... args)
69 return std::make_unique<rate_limiting_protocol>(
70 ms, std::make_unique<Protocol>(std::forward<Args>(args)...));
Root of a device tree.
Definition ossia/network/base/device.hpp:58
The node_base class.
Definition node.hpp:48
The parameter_base class.
Definition ossia/network/base/parameter.hpp:48
The protocol_base class.
Definition protocol.hpp:40
The value class.
Definition value.hpp:173