Calls on_change from a background thread whenever the combined input and output list changes. More...
#include <port_change_watcher.hpp>
Public Types | |
| using | Enumerate = std::function<std::vector<MidiPortInfo>()> |
| using | OnChange = std::function<void(const PortListDiff&)> |
Public Member Functions | |
| PortChangePoller ()=default | |
| PortChangePoller (const PortChangePoller &)=delete | |
| PortChangePoller & | operator= (const PortChangePoller &)=delete |
| ~PortChangePoller () | |
| void | start (Enumerate enumerate, OnChange on_change, std::chrono::milliseconds interval=std::chrono::milliseconds(1000)) |
| Start polling. | |
| void | stop () |
| bool | running () const |
Calls on_change from a background thread whenever the combined input and output list changes.
enumerate returns the current ports and runs on that thread. Destruction (or stop()) joins the thread, so no callback runs afterwards. stop() may be called from on_change, in which case the thread winds down and is joined by the next stop() or the destructor.
| using pulp::midi::PortChangePoller::Enumerate = std::function<std::vector<MidiPortInfo>()> |
| using pulp::midi::PortChangePoller::OnChange = std::function<void(const PortListDiff&)> |
|
default |
|
delete |
|
inline |
|
delete |
|
inline |
|
inline |
Start polling.
The baseline is taken on the calling thread before the worker starts, so a change right after start() is never missed. Restarts if already running.
|
inline |