Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
Loading...
Searching...
No Matches
kcenon::thread::event_bus::subscription Class Reference

Subscription handle for managing subscriptions. More...

#include <event_bus.h>

Collaboration diagram for kcenon::thread::event_bus::subscription:
Collaboration graph

Public Member Functions

 subscription ()=default
 
 subscription (event_bus *bus, std::type_index type, std::size_t id)
 
void unsubscribe ()
 Unsubscribe from events.
 
bool is_active () const
 Check if subscription is active.
 
 subscription (subscription &&other) noexcept
 
subscriptionoperator= (subscription &&other) noexcept
 
 subscription (const subscription &)=delete
 
subscriptionoperator= (const subscription &)=delete
 
 ~subscription ()
 

Private Attributes

event_busbus_ {nullptr}
 
std::type_index type_ {typeid(void)}
 
std::size_t id_ {0}
 

Detailed Description

Subscription handle for managing subscriptions.

Definition at line 65 of file event_bus.h.

Constructor & Destructor Documentation

◆ subscription() [1/4]

kcenon::thread::event_bus::subscription::subscription ( )
default

◆ subscription() [2/4]

kcenon::thread::event_bus::subscription::subscription ( event_bus * bus,
std::type_index type,
std::size_t id )
inline

Definition at line 68 of file event_bus.h.

◆ subscription() [3/4]

kcenon::thread::event_bus::subscription::subscription ( subscription && other)
inlinenoexcept

Definition at line 89 of file event_bus.h.

90 : bus_(other.bus_), type_(other.type_), id_(other.id_) {
91 other.bus_ = nullptr;
92 }

◆ subscription() [4/4]

kcenon::thread::event_bus::subscription::subscription ( const subscription & )
delete

◆ ~subscription()

kcenon::thread::event_bus::subscription::~subscription ( )
inline

Definition at line 109 of file event_bus.h.

109 {
110 unsubscribe();
111 }
void unsubscribe()
Unsubscribe from events.
Definition event_bus.h:74

References unsubscribe().

Here is the call graph for this function:

Member Function Documentation

◆ is_active()

bool kcenon::thread::event_bus::subscription::is_active ( ) const
inline

Check if subscription is active.

Definition at line 84 of file event_bus.h.

84 {
85 return bus_ != nullptr;
86 }

References bus_.

◆ operator=() [1/2]

subscription & kcenon::thread::event_bus::subscription::operator= ( const subscription & )
delete

◆ operator=() [2/2]

subscription & kcenon::thread::event_bus::subscription::operator= ( subscription && other)
inlinenoexcept

Definition at line 94 of file event_bus.h.

94 {
95 if (this != &other) {
97 bus_ = other.bus_;
98 type_ = other.type_;
99 id_ = other.id_;
100 other.bus_ = nullptr;
101 }
102 return *this;
103 }

References bus_, id_, type_, and unsubscribe().

Here is the call graph for this function:

◆ unsubscribe()

void kcenon::thread::event_bus::subscription::unsubscribe ( )
inline

Unsubscribe from events.

Definition at line 74 of file event_bus.h.

74 {
75 if (bus_) {
77 bus_ = nullptr;
78 }
79 }
void unsubscribe(std::type_index type, std::size_t id)
Unsubscribe a specific handler.
Definition event_bus.h:263

References bus_, id_, type_, and kcenon::thread::event_bus::unsubscribe().

Referenced by operator=(), and ~subscription().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ bus_

event_bus* kcenon::thread::event_bus::subscription::bus_ {nullptr}
private

Definition at line 114 of file event_bus.h.

114{nullptr};

Referenced by is_active(), operator=(), and unsubscribe().

◆ id_

std::size_t kcenon::thread::event_bus::subscription::id_ {0}
private

Definition at line 116 of file event_bus.h.

116{0};

Referenced by operator=(), and unsubscribe().

◆ type_

std::type_index kcenon::thread::event_bus::subscription::type_ {typeid(void)}
private

Definition at line 115 of file event_bus.h.

115{typeid(void)};

Referenced by operator=(), and unsubscribe().


The documentation for this class was generated from the following file: