Binance C++ Connector 2.0.0
Official C++ connectors for the Binance APIs
Loading...
Searching...
No Matches
binance::common::Subscription Class Reference

A registration made with on_event. More...

#include <websocket_common.hpp>

Public Member Functions

 Subscription ()=default
 Subscription (std::function< void()> unsubscribe)
 Subscription (Subscription &&other) noexcept
Subscription & operator= (Subscription &&other) noexcept
 Subscription (const Subscription &)=delete
Subscription & operator= (const Subscription &)=delete
 ~Subscription ()
void unsubscribe () noexcept
 Stops the callback.
void release () noexcept
 Detaches the callback from this handle: it then runs until the client is destroyed.

Detailed Description

A registration made with on_event.

Move-only: destroying it, or assigning over it, removes the callback. release() keeps the callback for the client's lifetime.

Constructor & Destructor Documentation

◆ Subscription() [1/4]

binance::common::Subscription::Subscription ( )
default

◆ Subscription() [2/4]

binance::common::Subscription::Subscription ( std::function< void()> unsubscribe)
inlineexplicit

◆ Subscription() [3/4]

binance::common::Subscription::Subscription ( Subscription && other)
inlinenoexcept

◆ Subscription() [4/4]

binance::common::Subscription::Subscription ( const Subscription & )
delete

◆ ~Subscription()

binance::common::Subscription::~Subscription ( )
inline

Member Function Documentation

◆ operator=() [1/2]

Subscription & binance::common::Subscription::operator= ( Subscription && other)
inlinenoexcept

◆ operator=() [2/2]

Subscription & binance::common::Subscription::operator= ( const Subscription & )
delete

◆ unsubscribe()

void binance::common::Subscription::unsubscribe ( )
inlinenoexcept

Stops the callback.

Safe to call more than once and after the client is gone, but not concurrently on the same object. A callback running on another thread of the client's executor is waited for (one on its own executor is not).

◆ release()

void binance::common::Subscription::release ( )
inlinenoexcept

Detaches the callback from this handle: it then runs until the client is destroyed.