MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Kriya::BroadcastAwaiter< T > Class Template Reference

Awaiter for suspending a coroutine until a BroadcastSource<T> fires. More...

#include <BroadcastAwaiter.hpp>

+ Inheritance diagram for MayaFlux::Kriya::BroadcastAwaiter< T >:
+ Collaboration diagram for MayaFlux::Kriya::BroadcastAwaiter< T >:

Public Member Functions

bool await_ready ()
 Returns true if a pending value is already available.
 
await_resume ()
 Return the delivered value on resume.
 
bool await_suspend (std::coroutine_handle<> handle)
 Register with the source and suspend, or consume a pending value that arrived in the race window and return false (no suspend).
 
 BroadcastAwaiter (BroadcastAwaiter &&) noexcept=default
 
 BroadcastAwaiter (const BroadcastAwaiter &)=delete
 
 BroadcastAwaiter (Vruta::BroadcastSource< T > &source)
 
void deliver (const T &value)
 Called by BroadcastSource::signal() from any thread.
 
bool filter_matches (const void *) const override
 BroadcastAwaiter has no filter semantics.
 
BroadcastAwaiteroperator= (BroadcastAwaiter &&) noexcept=delete
 
BroadcastAwaiteroperator= (const BroadcastAwaiter &)=delete
 
void try_resume (const void *) override
 Satisfies EventAwaiter interface.
 
 ~BroadcastAwaiter () override
 
- Public Member Functions inherited from MayaFlux::Kriya::EventAwaiter
 EventAwaiter ()=default
 
 EventAwaiter (const EventAwaiter &)=delete
 
 EventAwaiter (EventAwaiter &&) noexcept=default
 
EventAwaiteroperator= (const EventAwaiter &)=delete
 
EventAwaiteroperator= (EventAwaiter &&) noexcept=default
 
virtual ~EventAwaiter ()=default
 

Private Attributes

m_result {}
 
Vruta::BroadcastSource< T > & m_source
 

Additional Inherited Members

- Protected Attributes inherited from MayaFlux::Kriya::EventAwaiter
std::coroutine_handle m_handle
 
bool m_is_suspended {}
 

Detailed Description

template<typename T>
class MayaFlux::Kriya::BroadcastAwaiter< T >

Awaiter for suspending a coroutine until a BroadcastSource<T> fires.

Works with any coroutine type: SoundRoutine, GraphicsRoutine, Event, ComplexRoutine. The awaiter does not own the source; the source must outlive any suspended awaiter.

Edge-triggered: await_ready() returns true only when a value arrived before this co_await expression (pending slot occupied). Otherwise the coroutine suspends and is resumed by the next signal() call.

One BroadcastAwaiter may be registered against a BroadcastSource at a time. For fan-out to multiple consumers, use one BroadcastSource per consumer.

The captured shared_ptr to the BroadcastSource must be copied into a coroutine-local variable before first use, not referenced only through the lambda closure. The lambda closure lives on the caller's stack; the coroutine frame is heap-allocated and outlives the caller.

auto src = make_persistent_shared<Vruta::BroadcastSource<MyType>>();
auto routine = [src]() -> Vruta::Event {
auto local_src = src; // pull into coroutine frame
while (true) {
auto val = co_await local_src->next();
}
};
Coroutine type for event-driven suspension.
Definition Event.hpp:26
Template Parameters
TPayload type matching the bound BroadcastSource<T>.
See also
BroadcastSource

Definition at line 44 of file BroadcastAwaiter.hpp.


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