|
MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
|
Awaitable broadcast message stream for a network endpoint. More...
#include <NetworkSource.hpp>
Collaboration diagram for MayaFlux::Vruta::NetworkSource:Public Member Functions | |
| void | clear () |
| Clear all pending messages. | |
| bool | has_pending () const |
| Check if messages are pending. | |
| NetworkSource (const Core::EndpointInfo &info) | |
| Open a network endpoint and begin receiving. | |
| NetworkSource (const NetworkSource &)=delete | |
| NetworkSource (NetworkSource &&) noexcept=default | |
| Kriya::NetworkAwaiter | next_message () |
| Create an awaiter for the next message. | |
| NetworkSource & | operator= (const NetworkSource &)=delete |
| NetworkSource & | operator= (NetworkSource &&) noexcept=default |
| size_t | pending_count () const |
| Get number of pending messages. | |
| void | signal (const Core::NetworkMessage &message) |
| Signal that a message arrived (called from Asio IO thread) | |
| ~NetworkSource () | |
| Close the endpoint and release all resources. | |
Private Member Functions | |
| std::optional< Core::NetworkMessage > | pop_message () |
| void | register_waiter (Kriya::NetworkAwaiter *awaiter) |
| void | unregister_waiter (Kriya::NetworkAwaiter *awaiter) |
Private Attributes | |
| uint64_t | m_endpoint_id {} |
| Memory::LockFreeQueue< Core::NetworkMessage, QUEUE_CAPACITY > | m_queue |
| std::atomic< Kriya::NetworkAwaiter * > | m_waiters_head { nullptr } |
| Head of the intrusive lock-free waiter list. | |
Static Private Attributes | |
| static constexpr size_t | QUEUE_CAPACITY = 256 |
Friends | |
| class | Kriya::NetworkAwaiter |
Awaitable broadcast message stream for a network endpoint.
Opens and owns a network endpoint on construction. Any number of coroutines may co_await the same source simultaneously via next_message(). signal() broadcasts to all registered waiters on every incoming message.
Fully lock-free on all paths. Waiter registration uses an intrusive singly-linked list with an atomic head. signal() atomically detaches the entire list and resumes each awaiter. The message queue is a lock-free ring buffer shared by all waiters — each awaiter pops its own copy on resumption.
Endpoint lifecycle is internal. BackendRegistry is consulted in the constructor and destructor; the caller never touches NetworkService.
Definition at line 41 of file NetworkSource.hpp.