QcSessionLink Class
The session's side of its tick core (decision E-560): owns the core and, when it ticks on a thread of its own, that thread. More...
| Header: | #include <clientcore/tick/QcSessionLink.h> |
| Inherits: | QObject |
Public Types
Public Functions
| QcSessionLink(std::unique_ptr<QcTransport> transport, QcSessionLink::Handler handler) | |
| QcSessionLink(std::unique_ptr<QcSessionThread> thread, std::unique_ptr<QcTransport> transport, QcSessionLink::Handler handler) | |
| QcSessionLink(const QcSessionLink &) | |
| QcSessionLink(QcSessionLink &&) | |
| virtual | ~QcSessionLink() override |
| void | command(QcSessionCommand &&command) |
| std::optional<QcRoundTripSummary> | latency() const |
| QcLinkStats & | linkStats() const |
| quint64 | mirroredGiven() const |
| void | resetLatency() |
| void | start(const QcSessionCommand::Start &start, bool threaded) |
| bool | threaded() const |
| bool | tick() |
| QcTickTiming & | timing() const |
| QcSessionLink & | operator=(QcSessionLink &&) |
| QcSessionLink & | operator=(const QcSessionLink &) |
Static Public Members
| bool | threadWanted() |
Detailed Description
Commands go to the core and the core's events come back through one QcMailbox each (E-010); a queued call only wakes the other side. Without a thread (manual ticks, the timer in the session's thread, QTCRAFT_SESSION_THREAD=0) both are handed over directly. Lives in the session's thread; the core's thread touches only the event mailbox and the wake-up call. A transport that keeps its thread (TLS, decision E-872) is never moved: it is made in the session thread (QcNetworkClient) and the core joins it there.
Member Type Documentation
[alias] QcSessionLink::Handler
Takes the core's events.
Member Function Documentation
QcSessionLink::QcSessionLink(std::unique_ptr<QcTransport> transport, QcSessionLink::Handler handler)
handler takes the core's events in the session's thread, in the core's order. With a tick thread it may delete the link (without one the core calls it directly). While it runs a nested event loop, the events that arrive meanwhile wait until it returns (they must not overtake the rest of the batch), so such a loop sees the session stand.
QcSessionLink::QcSessionLink(std::unique_ptr<QcSessionThread> thread, std::unique_ptr<QcTransport> transport, QcSessionLink::Handler handler)
The core ticks on thread, where transport lives already (made there, never moved); the core is made here and joins the transport in that thread.
[delete] QcSessionLink::QcSessionLink(const QcSessionLink &)
Copy-constructs an instance of QcSessionLink. This function is deleted.
[delete] QcSessionLink::QcSessionLink(QcSessionLink &&)
Move-constructs an instance of QcSessionLink. This function is deleted.
[override virtual noexcept] QcSessionLink::~QcSessionLink()
Stops the core: the commands given before still reach it (a Disconnect still goes out). The connection closes in the core's thread, which ends after its socket's last frames left.
void QcSessionLink::command(QcSessionCommand &&command)
Hands command to the core; an intent equal to the one sent last is left out (the game sets it every frame).
std::optional<QcRoundTripSummary> QcSessionLink::latency() const
Returns the round trip to the server (decision E-886); safe to read from this thread.
QcLinkStats &QcSessionLink::linkStats() const
Returns the round trip and traffic of the connection (health line); safe to read from this thread.
quint64 QcSessionLink::mirroredGiven() const
Returns the number of mirrored commands given so far (QcSessionEvent::Prediction::mirroredApplied counts the same).
void QcSessionLink::resetLatency()
Forgets the round trips measured so far; safe from this thread.
void QcSessionLink::start(const QcSessionCommand::Start &start, bool threaded)
Starts the core with start on a thread of its own when threaded (only with the timer), else in this thread; a link made with a thread ticks there in any case. A transport that keeps its thread ticks in this thread then (with a warning; it should have been made in a session thread). Commands before start() reach the core at once.
[static] bool QcSessionLink::threadWanted()
Returns whether timer-driven sessions tick on a thread of their own: unless QTCRAFT_SESSION_THREAD=0.
bool QcSessionLink::threaded() const
Returns whether the core ticks on a thread of its own.
bool QcSessionLink::tick()
Runs one tick of the core, without a thread only (TickMode::Manual). Returns what QcSessionCore::tick returns.
QcTickTiming &QcSessionLink::timing() const
Returns the punctuality of the timer-driven ticks; safe to read and reset from this thread.
[delete] QcSessionLink &QcSessionLink::operator=(QcSessionLink &&)
Move-assigns other to this QcSessionLink instance. This function is deleted.
[delete] QcSessionLink &QcSessionLink::operator=(const QcSessionLink &)
Copy-assigns other to this QcSessionLink instance. This function is deleted.