MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Kriya::NetworkAwaiter Class Reference

Awaiter for suspending a coroutine until a network message arrives. More...

#include <NetworkAwaiter.hpp>

+ Collaboration diagram for MayaFlux::Kriya::NetworkAwaiter:

Public Member Functions

bool await_ready ()
 Check if a message is already queued.
 
Core::NetworkMessage await_resume ()
 Return the received message on resume.
 
void await_suspend (std::coroutine_handle<> handle)
 Suspend the coroutine and register with the source.
 
void deliver (const Core::NetworkMessage &message)
 Called by NetworkSource::signal() with the incoming message.
 
 NetworkAwaiter (const NetworkAwaiter &)=delete
 
 NetworkAwaiter (NetworkAwaiter &&) noexcept=default
 
 NetworkAwaiter (Vruta::NetworkSource &source)
 
NetworkAwaiteroperator= (const NetworkAwaiter &)=delete
 
NetworkAwaiteroperator= (NetworkAwaiter &&) noexcept=delete
 
 ~NetworkAwaiter ()
 

Private Attributes

std::coroutine_handle m_handle
 
bool m_is_suspended {}
 
std::atomic< NetworkAwaiter * > m_next { nullptr }
 Intrusive list link for lock-free waiter broadcast.
 
Core::NetworkMessage m_result
 
Vruta::NetworkSourcem_source
 

Friends

class Vruta::NetworkSource
 

Detailed Description

Awaiter for suspending a coroutine until a network message arrives.

Follows the same structural pattern as EventAwaiter. Works with any coroutine type: SoundRoutine, GraphicsRoutine, Event, ComplexRoutine.

Multiple awaiters may register against the same NetworkSource simultaneously. signal() delivers a copy of the message directly to each awaiter — no shared queue contention between waiters.

The queue on NetworkSource is used only by await_ready() for the no-suspend fast path. Once suspended, the awaiter receives its message via deliver() called directly from NetworkSource::signal().

The awaiter does not own the NetworkSource. The source must outlive any suspended awaiter.

Vruta::NetworkSource source({ .transport = NetworkTransport::UDP, .local_port = 8000 });
auto routine = [&source]() -> Vruta::Event {
while (true) {
auto msg = co_await source.next_message();
process(msg.data);
}
};
Coroutine type for event-driven suspension.
Definition Event.hpp:26
Awaitable broadcast message stream for a network endpoint.

Definition at line 38 of file NetworkAwaiter.hpp.


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