MT Core (C++)
Core library for replacing C++ standard in project usage
Loading...
Searching...
No Matches
mtcore::thread::BroadcastSubscription< T > Struct Template Reference

A subscription to a broadcaster. More...

#include <broadcaster.hpp>

Collaboration diagram for mtcore::thread::BroadcastSubscription< T >:

Public Member Functions

Result< void, AllocationErrorinit (Allocator &alloc)
 
Optional< T > receive_block ()
 
void deinit (Allocator &alloc)
 

Public Attributes

Arc< Inbox< T > > inbox
 

Detailed Description

template<typename T>
struct mtcore::thread::BroadcastSubscription< T >

A subscription to a broadcaster.

Template Parameters
TType of elements that can be received

Definition at line 46 of file broadcaster.hpp.

Member Function Documentation

◆ deinit()

template<typename T>
void mtcore::thread::BroadcastSubscription< T >::deinit ( Allocator & alloc)
inline

Definition at line 61 of file broadcaster.hpp.

61 {
62 if (inbox.valid()) {
63 inbox->close();
64 }
65 inbox.release(alloc);
66 }
A subscription to a broadcaster.
Here is the caller graph for this function:

◆ init()

template<typename T>
Result< void, AllocationError > mtcore::thread::BroadcastSubscription< T >::init ( Allocator & alloc)
inline

Definition at line 49 of file broadcaster.hpp.

49 {
50 if (auto inboxRes = inbox.init(alloc); inboxRes.is_error()) {
51 return inboxRes.error();
52 }
53 return inbox->init(alloc);
54 }
Here is the caller graph for this function:

◆ receive_block()

template<typename T>
Optional< T > mtcore::thread::BroadcastSubscription< T >::receive_block ( )
inline

Definition at line 56 of file broadcaster.hpp.

56 {
57 ensure(inbox.valid(), "SUBSCRIPTION IS NOT INITIALIZED!");
58 return inbox->receive_block();
59 }
#define ensure(check,...)
Ensures that a check holds true, aborts the program if not true Will print error if the condition is ...

Member Data Documentation

◆ inbox

template<typename T>
Arc<Inbox<T> > mtcore::thread::BroadcastSubscription< T >::inbox

Definition at line 47 of file broadcaster.hpp.


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