OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
ossia::net::device_parameter_index Class Reference

A thread-safe index of a device's parameters, by OSC address. More...

Inherits Nano::Observer.

Detailed Description

A thread-safe index of a device's parameters, by OSC address.

For protocols that receive on their own thread. find_node() cannot be used there: it locks each node only while reading its children, so nothing keeps the node it returns alive afterwards.

apply() holds a lock on the entry while the callback runs, and removals take the same lock - the device signals a removal before destroying the node, so a parameter cannot die under a running callback. The lock is per bucket group, not per map.

The callback must not add or remove nodes: re-entering the index deadlocks.

Public Member Functions

 device_parameter_index (ossia::net::device_base &dev)
 
 device_parameter_index (const device_parameter_index &)=delete
 
 device_parameter_index (device_parameter_index &&)=delete
 
device_parameter_indexoperator= (const device_parameter_index &)=delete
 
device_parameter_indexoperator= (device_parameter_index &&)=delete
 
template<typename F >
bool apply (std::string_view address, F &&f)
 
void clear ()
 
std::size_t size () const
 

Member Function Documentation

◆ apply()

template<typename F >
bool ossia::net::device_parameter_index::apply ( std::string_view  address,
F &&  f 
)
inline

Run f on the parameter at address, if there is one. Returns whether there was.

◆ clear()

void ossia::net::device_parameter_index::clear ( )
inline

Drop every entry. The owning protocol must call this before the device tears its tree down: it frees its children without signalling them.