Data subscriptions
Channels & subscriptions
Current version · 2.0.0
Returned by subscribe() to represent a callback subscription. Closing the owning scope reclaims remaining subscriptions.
Subscription::unsubscribe()
Stop one callback early.
Type
void Subscription::unsubscribe();Returns
void.
Details
- Call conditions: When the SDK keeps running but the callback is no longer needed.
- Use only to stop a callback early. Do not synchronously unsubscribe from inside that subscription’s own callback.
Errors
- Synchronous cancellation inside the callback is unsafe.
Example
channel is an existing read channel whose device has started, and on_sample is an application callback. Stop early from the application thread, not synchronously from inside this subscription’s own callback.
auto subscription = channel.subscribe(on_sample);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
subscription.unsubscribe();Complete example: subscription_config.cpp.
See also