12 #ifndef ROC_NETIO_NETWORK_LOOP_H_
13 #define ROC_NETIO_NETWORK_LOOP_H_
26 #include "roc_core/semaphore.h"
219 static void task_sem_cb_(uv_async_t* handle);
220 static void stop_sem_cb_(uv_async_t* handle);
222 virtual void handle_terminate_completed(
IConn&,
void*);
223 virtual void handle_close_completed(
BasicPort&,
void*);
228 void process_pending_tasks_();
237 void update_num_ports_();
239 void close_all_sems_();
240 void close_all_ports_();
256 bool loop_initialized_;
258 uv_async_t stop_sem_;
259 bool stop_sem_initialized_;
261 uv_async_t task_sem_;
262 bool task_sem_initialized_;
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
Intrusive doubly-linked list.
Thread-safe lock-free node-based intrusive multi-producer single-consumer queue.
Shared ownership intrusive pointer.
Base class for thread objects.
Connection acceptor interface.
Connection event handler interface.
Network task completion handler.
Resolver request result handler interface.
Termination handler interface.
PortHandle get_handle() const
Get created port handle.
AddTcpClientPort(TcpClientConfig &config, IConnHandler &conn_handler)
Set task parameters.
AddTcpServerPort(TcpServerConfig &config, IConnAcceptor &conn_acceptor)
Set task parameters.
PortHandle get_handle() const
Get created port handle.
Add UDP datagram sender/receiver port.
AddUdpPort(UdpConfig &config)
Set task parameters.
PortHandle get_handle() const
Get created port handle.
RemovePort(PortHandle handle)
Set task parameters.
Resolve endpoint address.
ResolveEndpointAddress(const address::EndpointUri &endpoint_uri)
Set task parameters.
const address::SocketAddr & get_address() const
Get resolved address.
Start receiving on UDP port.
StartUdpRecv(PortHandle handle, packet::IWriter &inbound_writer)
Set task parameters.
Start sending on UDP port.
packet::IWriter & get_outbound_writer() const
Get created writer for outbound packets.
StartUdpSend(PortHandle handle)
Set task parameters.
Subclasses for specific tasks.
Network event loop thread.
bool is_valid() const
Check if the object was successfully constructed.
NetworkLoop(core::IPool &packet_pool, core::IPool &buffer_pool, core::IArena &arena)
Initialize.
size_t num_ports() const
Get number of receiver and sender ports.
ROC_ATTR_NODISCARD bool schedule_and_wait(NetworkTask &task)
Enqueue a task for asynchronous execution and wait for its completion. The task should not be destroy...
void schedule(NetworkTask &task, INetworkTaskCompleter &completer)
Enqueue a task for asynchronous execution and return. The task should not be destroyed until the call...
virtual ~NetworkLoop()
Destroy. Stop all receivers and senders.
struct PortHandle * PortHandle
Opaque port handle.
Base class for network loop tasks.
Connection acceptor interface.
Connection event handler interface.
Network task completion handler.
Termination handler interface.
Intrusive doubly-linked list.
Multi-producer single-consumer queue.
AsyncOperationStatus
Asynchronous operation status.
Optionally constructed object.
TCP connection parameters.