2#include <ossia/detail/lockfree_queue.hpp>
3#include <ossia/detail/ptr_set.hpp>
4#include <ossia/network/base/device.hpp>
5#include <ossia/network/base/parameter.hpp>
7#include <ankerl/unordered_dense.h>
19class message_queue final :
public Nano::Observer
26 dev.on_parameter_removing.connect<&message_queue::on_param_removed>(*this);
31#if defined(__cpp_exceptions)
36 reg.first->remove_callback(reg.second.second);
45 reg.first->remove_callback(reg.second.second);
50 bool try_dequeue(ossia::received_value& v) {
return m_queue.try_dequeue(v); }
55 auto reg_it = m_reg.find(&p);
56 if(reg_it == m_reg.end())
59 m_queue.enqueue({ptr, val});
61 m_reg.insert({&p, {0, it}});
65 reg_it->second.first++;
71 auto it = m_reg.find(&p);
75 if(it->second.first <= 0)
91 ossia::mpmc_queue<received_value> m_queue;
95 std::pair<int, ossia::net::parameter_base::callback_index>>
99class global_message_queue final :
public Nano::Observer
104 dev.on_message.connect<&global_message_queue::on_message>(*this);
112 bool try_dequeue(ossia::received_value& v) {
return m_queue.try_dequeue(v); }
115 ossia::mpmc_queue<received_value> m_queue;
118struct coalescing_queue
121 using coalesced = ossia::hash_map<ossia::net::parameter_base*, ossia::value>;
123 smallfun::function<void(
const coalesced&)> callback;
125 ossia::mpmc_queue<ossia::received_value> noncritical;
126 ossia::mpmc_queue<ossia::received_value>
critical;
130 void process_messages()
132 ossia::received_value v;
136 coalesce.emplace(v.address, std::move(v.value));
142 while(noncritical.try_dequeue(v))
144 coalesce[v.address] = std::move(v.value);
void remove_callback(iterator it)
remove_callback Removes a callback identified by an iterator.
Definition callback_container.hpp:114
iterator add_callback(T &&callback)
add_callback Add a new callback.
Definition callback_container.hpp:90
Root of a device tree.
Definition ossia/network/base/device.hpp:58
The parameter_base class.
Definition ossia/network/base/parameter.hpp:48
virtual ossia::value value() const =0
Clone the current value without any network request.
The value class.
Definition value.hpp:173
bool critical
Means that the node is very important, e.g. a "play" message.
Definition node_attributes.hpp:92