Fray Engine
Loading...
Searching...
No Matches
fray::ipc::IPCManager Class Reference

Owns the TCP servers and the threads around them. More...

#include <ipc_manager.hpp>

Public Member Functions

 IPCManager (FrayManager &application)
 Creates an IPCManager with its own ThreadManager, which is convenient for tests.
 IPCManager (threads::ThreadManager &threads, FrayManager &application)
 Creates an IPCManager whose threads register with a ThreadManager owned by someone else.
 ~IPCManager ()
 Finishes IPC and application shutdown if not already finished.
F_void finish ()
 Stops IPC, releases servers, and shuts the application down exactly once. Call on the controlling thread; waits for local workers to finish.
TCPServerSP createTCPServer (F_ushort port)
 Creates a TCP server and starts it accepting. Must be called before start(). Not thread-safe; call from the thread that owns the IPCManager.
F_void removeTCPServer (F_ushort port)
 Forgets the server on the port (called by TCPServer::stop on the network thread). When no servers remain, cancels the monitor timer and stops the io_context so the network thread ends.
F_void start ()
 Starts the network thread and the engine message thread, then returns. Does nothing if already started. Also starts monitoring Electron Main and the once-a-second monitor timer.
F_void sendLoadingBuildInfo (const std::string &name, const std::string &version)
 Queues build information for the loading Renderer without waiting for it to start.
F_void sendWindowCommand (F_ulong operation, std::uint32_t windowId)
 Queues a window operation for Electron Main.
F_void startLoading (const std::string &name, const std::string &version)
 Queues the initial hidden loading window and its application information.
F_void setFontReader (std::function< std::vector< std::string >()> reader)
 Sets how installed font families are listed during startup. Call before startLoading().
F_void readSystemFonts ()
 Reads the installed font families on a worker thread, then hands them to the message thread, which records the startup milestone and delivers them to the application Renderer. Nothing waits for the scan.
F_void sendSystemFonts ()
 Message thread only. Sends the installed font families to the application Renderer, which keeps them for the session.
F_void loadingReadyToShow ()
 Records loading readiness and independently commands both startup windows.
F_void scheduleLoadingIntro ()
 Starts the Engine-owned, nonblocking loading logo intro timer.
F_void sendStartupProgress (const std::string &status="")
 Publishes the Engine's startup snapshot to the loading Renderer.
F_void recordStartupMilestone (unsigned milestone)
 Records an independent startup event and advances the Engine-owned transition.
F_void finishStartupIfReady ()
 Transitions only after startup milestones and the loading intro timer have both finished.
F_void startupFailed (const std::string &error)
 Records Main's independent report that application-window startup failed.
F_void mainFrameIsReady ()
 Records Main's announcement that the application window has a first frame.
F_void scheduleStartupWarning ()
 Warns about slow startup without completing it or blocking any process.
bool loadingWindowActive () const
 Whether startup logs should include the loading window.
F_void networkFinished ()
 Marks the network thread as finished and wakes wait(). Takes _networkMutex briefly. Called by the network thread as its last act, including after an exception.
F_void scheduleMonitor ()
 Arms the one-second monitor timer; each firing queues a router sweep and neighbor-monitor tick on the message thread, then re-arms. Runs on the network thread (timer handler); stops re-arming if the timer is cancelled or errors.
F_void pollShutdown ()
 Starts a short-interval local poll that advances shutdown until its terminal command is queued. Message thread only; repeated calls while polling do nothing.
F_void armShutdownPoll ()
 Advances shutdown now and re-arms the poll on the network thread while it is still pending.
F_void advanceShutdown ()
 Advances Engine-local shutdown and sends Main an independent terminal command when ready.
F_void wait ()
 Blocks until every server has stopped and the queued messages have been handled. While waiting it posts a heartbeat task to the message thread each second, then joins both threads. Subsequent calls on the controlling thread do nothing. Takes _networkMutex only while checking/waiting (released during the wait). Call from the owning (main) thread, not from the managed threads.
F_void stop ()
 Asks every server to stop (run on the network thread). Safe from any thread; wait() returns once the last one is gone.
bool send (Frame frame)
 Hands a message to the router and returns at once. Safe from any thread. The router delivers it now if its destination is ready, otherwise it waits in that destination's queue for as long as the header's ttl_ms allows (0 = until the destination is ready). Nothing is sent back to the caller either way.
F_void sendBuilt (const message::FrameOptions &options)
 Builds an Engine frame from the options and sends it with send(). Safe from any thread. Failures are logged, not returned.
F_void sendReady (ProcessKind destination, F_ulong destinationId)
 Sends a readiness notification without waiting for the destination.
Frame identify (const Frame &frame, message::Prefix &prefix)
 Assigns a routing UID without preventing delivery if UID generation fails.
F_void routeMulticast (const message::InData &incoming, bool record)
 Records one multicast command, handles the Engine recipient, and queues one frame to Main.
F_void route (const Frame &frame)
 Router thread only. Delivers an outgoing frame, or queues it if its destination is not ready. Readiness messages and broadcasts always go out at once, because they are how readiness is learned and who is reachable is not known yet. Everything else goes through the outgoing queue. Non-readiness messages also count toward the health progress counters. Assigns a UID when needed before handing the frame to its destination.
F_void transmit (Frame frame)
 Writes a frame to every connected client. Safe from any thread (posts to the network thread).
F_void handleReadiness (const message::InData &incoming)
 Message thread only. Handles readiness and health traffic from a neighbor. A READY marks the sender ready and delivers whatever was waiting for it. A REQUEST_READY is answered with a READY sent back to the sender only, so no peer ever has to announce to everyone because someone else asked. A PING is answered with a PONG carrying a health report; a PONG's report is passed to the neighbor monitor. Any message except READY also counts as the sender being heard. Messages from the Engine or broadcast senders are ignored.
F_void queueMessage (Frame frame)
 Called by the network thread: queues a received message for the engine message thread. On the message thread the frame is validated and routed. Messages for the Engine are logged, readiness is handled, commands go to FrayManager::handleApplicationMessage and receipts to FrayManager::handleReceipt. Messages for Electron Main or Renderer are recorded (disk log and Console) unless their flags opt out, then relayed with their UID. Assigns a UID when needed. Errors are logged.

Private Types

enum  StartupMilestone : unsigned {
  engineStarted = 1 , mainConnected = 2 , loadingReady = 4 , rendererConnected = 8 ,
  mainFrameReady = 16 , systemFontsReady = 32
}
using Neighbor = std::pair<ProcessKind, F_ulong>

Private Attributes

boost::asio::io_context _io
boost::asio::steady_timer _monitorTimer {_io}
boost::asio::steady_timer _startupTimer {_io}
boost::asio::steady_timer _loadingIntroTimer {_io}
std::atomic< bool > _loadingWindowActive {true}
bool _startupActive = false
bool _startupFailed = false
bool _loadingIntroElapsed = false
unsigned _startupMilestones = 0
unsigned _startupPercent = 0
unsigned _startupWarningGeneration = 0
threads::ThreadManager::Id _fontsThread = 0
std::function< std::vector< std::string >()> _fontReader = [] { return std::vector<std::string>(); }
std::vector< std::string > _systemFonts
bool _systemFontsLoaded = false
std::atomic< bool > _startupMainPending {false}
 Keeps the initial startup queue until Main first announces readiness.
std::vector< TCPServerSP > _servers
threads::TaskQueue _messages
bool _started = false
bool _waited = false
bool _finished = false
bool _shutdownCommandSent = false
boost::asio::steady_timer _shutdownTimer {_io}
bool _shutdownPolling = false
bool _shutdownConsoleStarted = false
threads::ThreadManager::Id _networkThread = 0
threads::ThreadManager::Id _messageThread = 0
std::mutex _networkMutex
std::condition_variable _networkWake
bool _networkStopped = false
uint64_t _heartbeat = 0
uint64_t _processedCount = 0
std::chrono::steady_clock::time_point _lastProgress = std::chrono::steady_clock::now()
FrayManager & _application
routing::OutgoingRouter< Neighbor, Frame > _outgoing
routing::NeighborMonitor< Neighbor > _monitor
std::unique_ptr< threads::ThreadManager > _ownedThreads
threads::ThreadManager * _threads

Static Private Attributes

static constexpr auto loadingIntroDuration = std::chrono::milliseconds(2000)
static constexpr unsigned allStartupMilestones
static constexpr unsigned startupMilestoneCount = 6

Detailed Description

Owns the TCP servers and the threads around them.

  • the network thread runs the io_context and is the only thread that touches sockets;
  • the engine message thread runs the message router, one message at a time, in arrival order. Messages are one-way. Nothing is sent back unless the engine calls send(). The router state (_outgoing, _monitor, counters) belongs to the engine message thread alone.

Definition at line 185 of file ipc_manager.hpp.

Member Typedef Documentation

◆ Neighbor

using fray::ipc::IPCManager::Neighbor = std::pair<ProcessKind, F_ulong>
private

A neighbor is identified by its process kind and instance ID.

Definition at line 264 of file ipc_manager.hpp.

Member Enumeration Documentation

◆ StartupMilestone

enum fray::ipc::IPCManager::StartupMilestone : unsigned
private
Enumerator
engineStarted 
mainConnected 
loadingReady 
rendererConnected 
mainFrameReady 
systemFontsReady 

Definition at line 208 of file ipc_manager.hpp.

Constructor & Destructor Documentation

◆ IPCManager() [1/2]

fray::ipc::IPCManager::IPCManager ( FrayManager & application)
inlineexplicit

Creates an IPCManager with its own ThreadManager, which is convenient for tests.

Parameters
applicationReceives engine messages and is shut down by the destructor; must outlive this object.

Definition at line 323 of file ipc_manager.hpp.

◆ IPCManager() [2/2]

fray::ipc::IPCManager::IPCManager ( threads::ThreadManager & threads,
FrayManager & application )
inline

Creates an IPCManager whose threads register with a ThreadManager owned by someone else.

Parameters
threadsShared ThreadManager; must outlive this object.
applicationReceives engine messages and is shut down by the destructor; must outlive this object.

Definition at line 336 of file ipc_manager.hpp.

◆ ~IPCManager()

fray::ipc::IPCManager::~IPCManager ( )
inline

Finishes IPC and application shutdown if not already finished.

Definition at line 347 of file ipc_manager.hpp.

Member Function Documentation

◆ advanceShutdown()

F_void fray::ipc::IPCManager::advanceShutdown ( )
inline

Advances Engine-local shutdown and sends Main an independent terminal command when ready.

Definition at line 782 of file ipc_manager.hpp.

◆ armShutdownPoll()

F_void fray::ipc::IPCManager::armShutdownPoll ( )
inline

Advances shutdown now and re-arms the poll on the network thread while it is still pending.

Definition at line 762 of file ipc_manager.hpp.

◆ createTCPServer()

TCPServerSP fray::ipc::IPCManager::createTCPServer ( F_ushort port)
inline

Creates a TCP server and starts it accepting. Must be called before start(). Not thread-safe; call from the thread that owns the IPCManager.

Parameters
portTCP port to listen on; 0 lets the OS pick a free port (read it from the result's port()).
Returns
The new server, also kept by this manager. Throws if finished or if the port cannot be bound.

Definition at line 385 of file ipc_manager.hpp.

◆ finish()

F_void fray::ipc::IPCManager::finish ( )
inline

Stops IPC, releases servers, and shuts the application down exactly once. Call on the controlling thread; waits for local workers to finish.

Definition at line 353 of file ipc_manager.hpp.

◆ finishStartupIfReady()

F_void fray::ipc::IPCManager::finishStartupIfReady ( )
inline

Transitions only after startup milestones and the loading intro timer have both finished.

Definition at line 652 of file ipc_manager.hpp.

◆ handleReadiness()

F_void fray::ipc::IPCManager::handleReadiness ( const message::InData & incoming)
inline

Message thread only. Handles readiness and health traffic from a neighbor. A READY marks the sender ready and delivers whatever was waiting for it. A REQUEST_READY is answered with a READY sent back to the sender only, so no peer ever has to announce to everyone because someone else asked. A PING is answered with a PONG carrying a health report; a PONG's report is passed to the neighbor monitor. Any message except READY also counts as the sender being heard. Messages from the Engine or broadcast senders are ignored.

Parameters
incomingParsed incoming message.

Definition at line 1105 of file ipc_manager.hpp.

◆ identify()

Frame fray::ipc::IPCManager::identify ( const Frame & frame,
message::Prefix & prefix )
inline

Assigns a routing UID without preventing delivery if UID generation fails.

Parameters
frameValidated frame to identify.
prefixDecoded frame prefix, updated when an identity is assigned.
Returns
Identified frame, or the original frame if identity assignment fails.

Definition at line 932 of file ipc_manager.hpp.

◆ loadingReadyToShow()

F_void fray::ipc::IPCManager::loadingReadyToShow ( )
inline

Records loading readiness and independently commands both startup windows.

Definition at line 564 of file ipc_manager.hpp.

◆ loadingWindowActive()

bool fray::ipc::IPCManager::loadingWindowActive ( ) const
inline

Whether startup logs should include the loading window.

Returns
True until its close command is queued.

Definition at line 714 of file ipc_manager.hpp.

◆ mainFrameIsReady()

F_void fray::ipc::IPCManager::mainFrameIsReady ( )
inline

Records Main's announcement that the application window has a first frame.

Definition at line 681 of file ipc_manager.hpp.

◆ networkFinished()

F_void fray::ipc::IPCManager::networkFinished ( )
inline

Marks the network thread as finished and wakes wait(). Takes _networkMutex briefly. Called by the network thread as its last act, including after an exception.

Definition at line 720 of file ipc_manager.hpp.

◆ pollShutdown()

F_void fray::ipc::IPCManager::pollShutdown ( )
inline

Starts a short-interval local poll that advances shutdown until its terminal command is queued. Message thread only; repeated calls while polling do nothing.

Definition at line 753 of file ipc_manager.hpp.

◆ queueMessage()

F_void fray::ipc::IPCManager::queueMessage ( Frame frame)
inline

Called by the network thread: queues a received message for the engine message thread. On the message thread the frame is validated and routed. Messages for the Engine are logged, readiness is handled, commands go to FrayManager::handleApplicationMessage and receipts to FrayManager::handleReceipt. Messages for Electron Main or Renderer are recorded (disk log and Console) unless their flags opt out, then relayed with their UID. Assigns a UID when needed. Errors are logged.

Parameters
frameComplete received frame.

Definition at line 1194 of file ipc_manager.hpp.

◆ readSystemFonts()

F_void fray::ipc::IPCManager::readSystemFonts ( )
inline

Reads the installed font families on a worker thread, then hands them to the message thread, which records the startup milestone and delivers them to the application Renderer. Nothing waits for the scan.

Definition at line 529 of file ipc_manager.hpp.

◆ recordStartupMilestone()

F_void fray::ipc::IPCManager::recordStartupMilestone ( unsigned milestone)
inline

Records an independent startup event and advances the Engine-owned transition.

Parameters
milestoneBit identifying the completed milestone.

Definition at line 635 of file ipc_manager.hpp.

◆ removeTCPServer()

F_void fray::ipc::IPCManager::removeTCPServer ( F_ushort port)
inline

Forgets the server on the port (called by TCPServer::stop on the network thread). When no servers remain, cancels the monitor timer and stops the io_context so the network thread ends.

Parameters
portPort of the server to remove; nothing is removed if none matches.

Definition at line 401 of file ipc_manager.hpp.

◆ route()

F_void fray::ipc::IPCManager::route ( const Frame & frame)
inline

Router thread only. Delivers an outgoing frame, or queues it if its destination is not ready. Readiness messages and broadcasts always go out at once, because they are how readiness is learned and who is reachable is not known yet. Everything else goes through the outgoing queue. Non-readiness messages also count toward the health progress counters. Assigns a UID when needed before handing the frame to its destination.

Parameters
frameFrame to route; an unparsable frame is logged and dropped.

Definition at line 1043 of file ipc_manager.hpp.

◆ routeMulticast()

F_void fray::ipc::IPCManager::routeMulticast ( const message::InData & incoming,
bool record )
inline

Records one multicast command, handles the Engine recipient, and queues one frame to Main.

Parameters
incomingParsed, UID-stamped multicast frame.
recordWhether this arrival needs its command record.

Definition at line 957 of file ipc_manager.hpp.

◆ scheduleLoadingIntro()

F_void fray::ipc::IPCManager::scheduleLoadingIntro ( )
inline

Starts the Engine-owned, nonblocking loading logo intro timer.

Definition at line 578 of file ipc_manager.hpp.

◆ scheduleMonitor()

F_void fray::ipc::IPCManager::scheduleMonitor ( )
inline

Arms the one-second monitor timer; each firing queues a router sweep and neighbor-monitor tick on the message thread, then re-arms. Runs on the network thread (timer handler); stops re-arming if the timer is cancelled or errors.

Definition at line 733 of file ipc_manager.hpp.

◆ scheduleStartupWarning()

F_void fray::ipc::IPCManager::scheduleStartupWarning ( )
inline

Warns about slow startup without completing it or blocking any process.

Definition at line 687 of file ipc_manager.hpp.

◆ send()

bool fray::ipc::IPCManager::send ( Frame frame)
inline

Hands a message to the router and returns at once. Safe from any thread. The router delivers it now if its destination is ready, otherwise it waits in that destination's queue for as long as the header's ttl_ms allows (0 = until the destination is ready). Nothing is sent back to the caller either way.

Parameters
frameComplete frame to send; must not be null.
Returns
true if it was queued for the router; false (and an error is logged) if frame is null or the message thread is shutting down.

Definition at line 877 of file ipc_manager.hpp.

◆ sendBuilt()

F_void fray::ipc::IPCManager::sendBuilt ( const message::FrameOptions & options)
inline

Builds an Engine frame from the options and sends it with send(). Safe from any thread. Failures are logged, not returned.

Parameters
optionsDestination, command, payload and header fields for the message.

Definition at line 898 of file ipc_manager.hpp.

◆ sendLoadingBuildInfo()

F_void fray::ipc::IPCManager::sendLoadingBuildInfo ( const std::string & name,
const std::string & version )
inline

Queues build information for the loading Renderer without waiting for it to start.

Parameters
namePublic build name.
versionApplication version string.

Definition at line 452 of file ipc_manager.hpp.

◆ sendReady()

F_void fray::ipc::IPCManager::sendReady ( ProcessKind destination,
F_ulong destinationId )
inline

Sends a readiness notification without waiting for the destination.

Parameters
destinationProcess kind receiving the notification.
destinationIdRecipient instance identifier.

Definition at line 916 of file ipc_manager.hpp.

◆ sendStartupProgress()

F_void fray::ipc::IPCManager::sendStartupProgress ( const std::string & status = "")
inline

Publishes the Engine's startup snapshot to the loading Renderer.

Parameters
statusOptional warning or error displayed separately from the latest log line.

Definition at line 607 of file ipc_manager.hpp.

◆ sendSystemFonts()

F_void fray::ipc::IPCManager::sendSystemFonts ( )
inline

Message thread only. Sends the installed font families to the application Renderer, which keeps them for the session.

Definition at line 548 of file ipc_manager.hpp.

◆ sendWindowCommand()

F_void fray::ipc::IPCManager::sendWindowCommand ( F_ulong operation,
std::uint32_t windowId )
inline

Queues a window operation for Electron Main.

Parameters
operationWindow command to send.
windowIdRenderer window instance to operate on.

Definition at line 472 of file ipc_manager.hpp.

◆ setFontReader()

F_void fray::ipc::IPCManager::setFontReader ( std::function< std::vector< std::string >()> reader)
inline

Sets how installed font families are listed during startup. Call before startLoading().

Parameters
readerFunction returning the family names; it runs on a worker thread.

Definition at line 520 of file ipc_manager.hpp.

◆ start()

F_void fray::ipc::IPCManager::start ( )
inline

Starts the network thread and the engine message thread, then returns. Does nothing if already started. Also starts monitoring Electron Main and the once-a-second monitor timer.

Definition at line 425 of file ipc_manager.hpp.

◆ startLoading()

F_void fray::ipc::IPCManager::startLoading ( const std::string & name,
const std::string & version )
inline

Queues the initial hidden loading window and its application information.

Parameters
namePublic application build name.
versionApplication version string.

Definition at line 490 of file ipc_manager.hpp.

◆ startupFailed()

F_void fray::ipc::IPCManager::startupFailed ( const std::string & error)
inline

Records Main's independent report that application-window startup failed.

Parameters
errorHuman-readable failure shown on the loading window.

Definition at line 670 of file ipc_manager.hpp.

◆ stop()

F_void fray::ipc::IPCManager::stop ( )
inline

Asks every server to stop (run on the network thread). Safe from any thread; wait() returns once the last one is gone.

Definition at line 859 of file ipc_manager.hpp.

◆ transmit()

F_void fray::ipc::IPCManager::transmit ( Frame frame)
inline

Writes a frame to every connected client. Safe from any thread (posts to the network thread).

Parameters
frameFrame to broadcast.

Definition at line 1087 of file ipc_manager.hpp.

◆ wait()

F_void fray::ipc::IPCManager::wait ( )
inline

Blocks until every server has stopped and the queued messages have been handled. While waiting it posts a heartbeat task to the message thread each second, then joins both threads. Subsequent calls on the controlling thread do nothing. Takes _networkMutex only while checking/waiting (released during the wait). Call from the owning (main) thread, not from the managed threads.

Definition at line 838 of file ipc_manager.hpp.

Member Data Documentation

◆ _application

FrayManager& fray::ipc::IPCManager::_application
private

The application that handles engine messages; must outlive this object.

Definition at line 262 of file ipc_manager.hpp.

◆ _finished

bool fray::ipc::IPCManager::_finished = false
private

True after the controlling thread has finished IPC and application shutdown.

Definition at line 236 of file ipc_manager.hpp.

◆ _fontReader

std::function<std::vector<std::string>()> fray::ipc::IPCManager::_fontReader = [] { return std::vector<std::string>(); }
private

Lists the installed font families; replaced before startLoading(). Reports none by default so tests need no platform font libraries.

Definition at line 220 of file ipc_manager.hpp.

◆ _fontsThread

threads::ThreadManager::Id fray::ipc::IPCManager::_fontsThread = 0
private

Reads the installed font families in the background during startup.

Definition at line 218 of file ipc_manager.hpp.

◆ _heartbeat

uint64_t fray::ipc::IPCManager::_heartbeat = 0
private

Counter bumped on the message thread by wait(); lets a health report show that thread is alive.

Definition at line 256 of file ipc_manager.hpp.

◆ _io

boost::asio::io_context fray::ipc::IPCManager::_io
private

Boost io_context run by the network thread.

Definition at line 189 of file ipc_manager.hpp.

◆ _lastProgress

std::chrono::steady_clock::time_point fray::ipc::IPCManager::_lastProgress = std::chrono::steady_clock::now()
private

When _processedCount last changed; message thread only.

Definition at line 260 of file ipc_manager.hpp.

◆ _loadingIntroElapsed

bool fray::ipc::IPCManager::_loadingIntroElapsed = false
private

Definition at line 203 of file ipc_manager.hpp.

◆ _loadingIntroTimer

boost::asio::steady_timer fray::ipc::IPCManager::_loadingIntroTimer {_io}
private

Tracks the loading logo intro independently of startup milestones.

Definition at line 195 of file ipc_manager.hpp.

◆ _loadingWindowActive

std::atomic<bool> fray::ipc::IPCManager::_loadingWindowActive {true}
private

Whether startup logs still include the loading window.

Definition at line 199 of file ipc_manager.hpp.

◆ _messages

threads::TaskQueue fray::ipc::IPCManager::_messages
private

Queue drained in order by the engine message thread.

Definition at line 230 of file ipc_manager.hpp.

◆ _messageThread

threads::ThreadManager::Id fray::ipc::IPCManager::_messageThread = 0
private

ThreadManager id of the engine message thread.

Definition at line 248 of file ipc_manager.hpp.

◆ _monitor

routing::NeighborMonitor<Neighbor> fray::ipc::IPCManager::_monitor
private

Health monitor for neighbors: its callbacks send probes/pings, read the router's state, and apply state changes (marking ready, discarding queues of down neighbors, cancelling prompts if Electron Main is lost). Message thread only.

Definition at line 273 of file ipc_manager.hpp.

◆ _monitorTimer

boost::asio::steady_timer fray::ipc::IPCManager::_monitorTimer {_io}
private

Fires once a second to queue a router sweep and a neighbor-monitor tick.

Definition at line 191 of file ipc_manager.hpp.

◆ _networkMutex

std::mutex fray::ipc::IPCManager::_networkMutex
private

Guards _networkStopped; paired with _networkWake.

Definition at line 250 of file ipc_manager.hpp.

◆ _networkStopped

bool fray::ipc::IPCManager::_networkStopped = false
private

True once the network thread has finished (guarded by _networkMutex).

Definition at line 254 of file ipc_manager.hpp.

◆ _networkThread

threads::ThreadManager::Id fray::ipc::IPCManager::_networkThread = 0
private

ThreadManager id of the network thread.

Definition at line 246 of file ipc_manager.hpp.

◆ _networkWake

std::condition_variable fray::ipc::IPCManager::_networkWake
private

Notified when the network thread finishes so wait() can continue.

Definition at line 252 of file ipc_manager.hpp.

◆ _outgoing

routing::OutgoingRouter<Neighbor, Frame> fray::ipc::IPCManager::_outgoing
private
Initial value:
{
[this](Neighbor, const Frame &frame) { transmit(frame); }}
F_void transmit(Frame frame)
Writes a frame to every connected client. Safe from any thread (posts to the network thread).
std::pair< ProcessKind, F_ulong > Neighbor
std::shared_ptr< const std::vector< F_uchar > > Frame
Shared, immutable, fully built frame (prefix + header + payload); shared between threads without copy...

Readiness table and waiting-message queues per neighbor instance; delivery writes to every client via transmit().

Definition at line 267 of file ipc_manager.hpp.

◆ _ownedThreads

std::unique_ptr<threads::ThreadManager> fray::ipc::IPCManager::_ownedThreads
private

ThreadManager created by the single-argument constructor; null when an external one is used.

Definition at line 314 of file ipc_manager.hpp.

◆ _processedCount

uint64_t fray::ipc::IPCManager::_processedCount = 0
private

Number of non-readiness messages processed (sent or received); message thread only.

Definition at line 258 of file ipc_manager.hpp.

◆ _servers

std::vector<TCPServerSP> fray::ipc::IPCManager::_servers
private

Servers owned here; touched on the creating thread before start() and on the network thread afterwards.

Definition at line 228 of file ipc_manager.hpp.

◆ _shutdownCommandSent

bool fray::ipc::IPCManager::_shutdownCommandSent = false
private

True once the terminal Engine command has been scheduled; message thread only.

Definition at line 238 of file ipc_manager.hpp.

◆ _shutdownConsoleStarted

bool fray::ipc::IPCManager::_shutdownConsoleStarted = false
private

True after Console delivery has been asked to drain; message thread only.

Definition at line 244 of file ipc_manager.hpp.

◆ _shutdownPolling

bool fray::ipc::IPCManager::_shutdownPolling = false
private

True while the fast shutdown poll is armed; message thread only.

Definition at line 242 of file ipc_manager.hpp.

◆ _shutdownTimer

boost::asio::steady_timer fray::ipc::IPCManager::_shutdownTimer {_io}
private

Fires while shutdown is pending so progress is noticed within milliseconds.

Definition at line 240 of file ipc_manager.hpp.

◆ _started

bool fray::ipc::IPCManager::_started = false
private

True once start() has run.

Definition at line 232 of file ipc_manager.hpp.

◆ _startupActive

bool fray::ipc::IPCManager::_startupActive = false
private

Startup milestone state, owned by the message thread.

Definition at line 201 of file ipc_manager.hpp.

◆ _startupFailed

bool fray::ipc::IPCManager::_startupFailed = false
private

Definition at line 202 of file ipc_manager.hpp.

◆ _startupMainPending

std::atomic<bool> fray::ipc::IPCManager::_startupMainPending {false}
private

Keeps the initial startup queue until Main first announces readiness.

Definition at line 226 of file ipc_manager.hpp.

◆ _startupMilestones

unsigned fray::ipc::IPCManager::_startupMilestones = 0
private

Definition at line 204 of file ipc_manager.hpp.

◆ _startupPercent

unsigned fray::ipc::IPCManager::_startupPercent = 0
private

Definition at line 205 of file ipc_manager.hpp.

◆ _startupTimer

boost::asio::steady_timer fray::ipc::IPCManager::_startupTimer {_io}
private

Reports startup that has taken longer than expected.

Definition at line 193 of file ipc_manager.hpp.

◆ _startupWarningGeneration

unsigned fray::ipc::IPCManager::_startupWarningGeneration = 0
private

Distinguishes the current slow-start warning from cancelled older timers.

Definition at line 207 of file ipc_manager.hpp.

◆ _systemFonts

std::vector<std::string> fray::ipc::IPCManager::_systemFonts
private

The installed font families once read; message thread only.

Definition at line 222 of file ipc_manager.hpp.

◆ _systemFontsLoaded

bool fray::ipc::IPCManager::_systemFontsLoaded = false
private

Whether _systemFonts has been read, even if the computer has none; message thread only.

Definition at line 224 of file ipc_manager.hpp.

◆ _threads

threads::ThreadManager* fray::ipc::IPCManager::_threads
private

The ThreadManager that registers the network and message threads (owned or external).

Definition at line 316 of file ipc_manager.hpp.

◆ _waited

bool fray::ipc::IPCManager::_waited = false
private

True once wait() has joined the IPC workers on the controlling thread.

Definition at line 234 of file ipc_manager.hpp.

◆ allStartupMilestones

unsigned fray::ipc::IPCManager::allStartupMilestones
staticconstexprprivate
Initial value:

Every milestone that must be recorded before the loading window gives way to the application window.

Definition at line 214 of file ipc_manager.hpp.

◆ loadingIntroDuration

auto fray::ipc::IPCManager::loadingIntroDuration = std::chrono::milliseconds(2000)
staticconstexprprivate

Must be at least as long as the loading Renderer logo intro's total GSAP duration.

Definition at line 197 of file ipc_manager.hpp.

◆ startupMilestoneCount

unsigned fray::ipc::IPCManager::startupMilestoneCount = 6
staticconstexprprivate

Definition at line 216 of file ipc_manager.hpp.


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