CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
Loading...
Searching...
No Matches
cmlabs::NetworkThread Class Reference

Bookkeeping for one worker thread of a NetworkChannel (per listener or connection). More...

#include <NetworkManager.h>

Collaboration diagram for cmlabs::NetworkThread:
[legend]

Public Member Functions

 NetworkThread (NetworkChannel *parent, uint64 id)
 ~NetworkThread ()

Public Attributes

uint64 id
 Connection or listener id served by this thread.
uint32 threadID
 ThreadManager id of the worker thread.
ThreadHandle hWorker
 OS-level handle of the worker thread (0 until started).
bool reaping
 Set by whichever teardown path has CLAIMED this object for freeing.
uint16 port
 Local port (listeners) or 0.
TCPListener * listener
 Listener served (owned), or NULL for connections.
NetworkConnection * con
 Connection served (owned), or NULL for listeners.
uint32 defaultProtocol
 Fallback PROTOCOL_* when auto-detection is inconclusive.
uint32 autoProtocols
 PROTOCOL_* bit set to auto-detect among.
uint32 autoProtocolTimeout
 Milliseconds allowed for protocol sniffing.
bool autoreconnect
 Re-establish the connection automatically on failure.
bool shouldContinue
 Loop control flag: thread exits when false.
bool isRunning
 True while the worker loop is active.
bool isAsync
 Push to receiver (true) or queue for waitFor*() (false).
HTTPRequest * lastRequest
 Last request pending a reply on this HTTP connection.
NetworkChannel * parent
 Owning channel (not owned).

Detailed Description

Bookkeeping for one worker thread of a NetworkChannel (per listener or connection).

Plain data holder tying together the thread, its socket object (listener or connection), protocol settings and lifecycle flags. Created and owned by NetworkChannel; not for direct external use.

Definition at line 431 of file NetworkManager.h.

Constructor & Destructor Documentation

◆ NetworkThread()

cmlabs::NetworkThread::NetworkThread ( NetworkChannel * parent,
uint64 id )
Parameters
parentOwning channel.
idConnection/listener id this thread serves.

Definition at line 28 of file NetworkManager.cpp.

References autoProtocols, autoProtocolTimeout, autoreconnect, con, defaultProtocol, hWorker, isAsync, isRunning, lastRequest, listener, parent, port, reaping, and shouldContinue.

◆ ~NetworkThread()

cmlabs::NetworkThread::~NetworkThread ( )

Definition at line 48 of file NetworkManager.cpp.

References autoreconnect, con, isRunning, lastRequest, listener, and shouldContinue.

Member Data Documentation

◆ autoProtocols

◆ autoProtocolTimeout

uint32 cmlabs::NetworkThread::autoProtocolTimeout

◆ autoreconnect

◆ con

◆ defaultProtocol

◆ hWorker

ThreadHandle cmlabs::NetworkThread::hWorker

OS-level handle of the worker thread (0 until started).

Definition at line 439 of file NetworkManager.h.

Referenced by cmlabs::NetworkChannel::autoDetectConnection(), NetworkThread(), cmlabs::NetworkChannel::startConnection(), and cmlabs::NetworkChannel::startListener().

◆ id

◆ isAsync

◆ isRunning

◆ lastRequest

HTTPRequest* cmlabs::NetworkThread::lastRequest

Last request pending a reply on this HTTP connection.

Definition at line 455 of file NetworkManager.h.

Referenced by NetworkThread(), and ~NetworkThread().

◆ listener

TCPListener* cmlabs::NetworkThread::listener

Listener served (owned), or NULL for connections.

Definition at line 446 of file NetworkManager.h.

Referenced by cmlabs::NetworkChannel::NetworkListenerRun(), NetworkThread(), cmlabs::NetworkChannel::startListener(), and ~NetworkThread().

◆ parent

◆ port

uint16 cmlabs::NetworkThread::port

Local port (listeners) or 0.

Definition at line 445 of file NetworkManager.h.

Referenced by cmlabs::NetworkChannel::NetworkListenerRun(), NetworkThread(), and cmlabs::NetworkChannel::startListener().

◆ reaping

bool cmlabs::NetworkThread::reaping

Set by whichever teardown path has CLAIMED this object for freeing.

Map-absence is NOT proof of exclusive ownership: shutdown() snapshots thread pointers under channelMutex and frees them after releasing it, so a pointer can outlive its map entry. This flag closes that double-delete window.

Definition at line 440 of file NetworkManager.h.

Referenced by cmlabs::NetworkChannel::endConnection(), NetworkThread(), cmlabs::NetworkChannel::shutdown(), and cmlabs::NetworkChannel::stopListener().

◆ shouldContinue

◆ threadID


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