Move-only RAII wrapper that pairs a SubscriberToken with an unsubscribe callable. Destroying a Subscription automatically cancels it.
More...
#include <Subscription.hpp>
|
|
| Subscription () noexcept=default |
| | Default-construct an inactive Subscription.
|
| | Subscription (SubscriberToken token, std::function< void()> unsubscribe) |
| | Construct from a token and an unsubscribe callable.
|
|
| Subscription (Subscription &&other) noexcept |
| | Move constructor.
|
|
Subscription & | operator= (Subscription &&other) noexcept |
| | Move assignment operator.
|
|
| Subscription (const Subscription &)=delete |
|
Subscription & | operator= (const Subscription &)=delete |
|
| ~Subscription () |
| | Destructor — automatically cancels an active subscription.
|
|
void | cancel () noexcept |
| | Cancel the subscription. Safe to call multiple times (idempotent).
|
| bool | isActive () const noexcept |
| | Check whether this subscription is still active.
|
| SubscriberToken | token () const noexcept |
| | Access the underlying token (e.g. for logging or debugging).
|
Move-only RAII wrapper that pairs a SubscriberToken with an unsubscribe callable. Destroying a Subscription automatically cancels it.
Observables (MeasurementManager, Logger, …) return a Subscription from their subscribe methods. The holder can call cancel() explicitly or simply let the Subscription go out of scope.
◆ Subscription()
| eduart::subscription::Subscription::Subscription |
( |
SubscriberToken | token, |
|
|
std::function< void()> | unsubscribe ) |
|
inline |
Construct from a token and an unsubscribe callable.
- Parameters
-
| [in] | token | The token identifying the subscription. |
| [in] | unsubscribe | Callable that removes the subscription from the observable. |
◆ isActive()
| bool eduart::subscription::Subscription::isActive |
( |
| ) |
const |
|
inlinenoexcept |
Check whether this subscription is still active.
- Returns
- true if the subscription has not been cancelled.
◆ token()
Access the underlying token (e.g. for logging or debugging).
- Returns
- The SubscriberToken associated with this subscription.
The documentation for this class was generated from the following file: