OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
ossia::qt::qml_tcp_outbound_socket::state Struct Reference

Inherits Nano::Observer.

Detailed Description

Owns the transport and every asio-side callback.

The Nano::Observer is here rather than on the QObject on purpose: the signals it listens to live in socket, a member of this very object, so the (unsynchronized) slot lists can only be mutated while the whole state is being destroyed, at which point no handler can still be running. The QObject, which is destroyed on the Qt thread while the asio thread may be firing, is only ever reached under qt_mutex.

Public Member Functions

 state (const ossia::net::outbound_socket_configuration &conf, boost::asio::io_context &ctx, ossia::net::framing f=ossia::net::framing::none, const std::string &delim={}, ossia::net::encoding e=ossia::net::encoding::none)
 
void write_encoded (const char *data, std::size_t sz)
 
void detach ()
 
template<typename F >
void post_to_qt (F &&f)
 
void fire_open ()
 Nano slots, always on the asio thread.
 
void fire_fail ()
 
void fire_close ()
 
void notify_closed ()
 Single-shot close notification, whoever observed it first.
 

Public Attributes

ossia::net::tcp_client socket
 
std::atomic_bool alive {true}
 
std::atomic_bool closed {false}
 
ossia::net::framing framing {ossia::net::framing::none}
 
ossia::net::encoding enc {ossia::net::encoding::none}
 
char line_delimiter [8] = {}
 
decoder_type decoder
 
std::mutex qt_mutex
 
qml_tcp_outbound_socket * self {}
 

Member Data Documentation

◆ qt_mutex

std::mutex ossia::qt::qml_tcp_outbound_socket::state::qt_mutex

Guards self, which is cleared before the QObject starts dying. Held for the whole asio -> Qt handover, so the QObject cannot be destroyed in the middle of one.