Lumiera  0.pre.03
»edit your freedom«
SteamDispatcher Class Reference

#include "steam/control/steam-dispatcher.hpp"

Description

Guard to manage processing commands to operate on the session.

A static application facility, actually backing and implementing the »session subsystem«. Embedded within the implementation of this class is the »session loop thread« to perform any session mutation commands and to activate the Builder, which translates the session contents into a render nodes network. Also embedded herein is the implementation of steam::control::SessionCommandService

Warning
destroying this object while isRunning() will terminate the Application unconditionally.

Definition at line 77 of file steam-dispatcher.hpp.

Public Member Functions

void activate ()
 activate processing of enqueued session commands. More...
 
void awaitDeactivation ()
 block until the dispatcher has actually reached disabled state. More...
 
void clear ()
 discard any commands waiting in the dispatcher queue
 
void deactivate ()
 halt further processing of session commands More...
 
bool empty () const
 
bool isRunning ()
 whether the »session subsystem« is operational. More...
 
void requestStop () noexcept
 signal to the loop thread that it needs to terminate. More...
 
bool start (Subsys::SigTerm)
 starting the SteamDispatcher means to start the session subsystem. More...
 

Static Public Attributes

static lib::Depend< SteamDispatcherinstance
 storage for Singleton access
 

Friends

class lib::DependencyFactory< SteamDispatcher >
 

Private Member Functions

void endRunningLoopState ()
 

Private Attributes

bool active_ {false}
 
unique_ptr< DispatcherLooprunningLoop_
 

Additional Inherited Members

- Static Public Member Functions inherited from Sync<>
static MonitorgetMonitor (Sync const *forThis)
 

Member Function Documentation

◆ start()

bool start ( Subsys::SigTerm  termNotification)

starting the SteamDispatcher means to start the session subsystem.

Returns
false when starting failed since it is already running...
Remarks
this function implements the start operation for the »session subsystem«. More specifically, this operation starts a new thread to perform the session loop, which means to perform commands and trigger the builder. It might block temporarily for synchronisation with this new thread and while opening the SessionCommand facade.

Definition at line 352 of file steam-dispatcher.cpp.

References SteamDispatcher::endRunningLoopState().

+ Here is the call graph for this function:

◆ isRunning()

bool isRunning ( )

whether the »session subsystem« is operational.

Returns
true if the session loop thread has been fully started and is not (yet) completely terminated.

Definition at line 398 of file steam-dispatcher.cpp.

◆ requestStop()

void requestStop ( )
noexcept

signal to the loop thread that it needs to terminate.

Note
the immediate consequence is to close SessionCommandService

Definition at line 409 of file steam-dispatcher.cpp.

References ERROR_LOG_AND_IGNORE.

◆ activate()

void activate ( )

activate processing of enqueued session commands.

Remarks
command processing serves as public external interface to the session. This call is used by the session lifecycle (SessManagerImpl) when the session is brought up; any other invocation runs danger to mess up the session lifecycle state and process commands on a deconfigured session. In case the dispatcher loop is not actually running, the activation state is stored and applied accordingly later, when the loop is fired up.

Definition at line 430 of file steam-dispatcher.cpp.

◆ deactivate()

void deactivate ( )

halt further processing of session commands

Note
the processing itself runs in a separate thread, thus any currently ongoing command or builder execution will be completed prior to this setting to take effect. If the intention is to halt processing because the session is about to dismantled, it is mandatory to awaitDeactivation()

Definition at line 446 of file steam-dispatcher.cpp.

◆ awaitDeactivation()

void awaitDeactivation ( )

block until the dispatcher has actually reached disabled state.

Warning
beware of invoking this function from within the session thread, since the waiting relies on the very lock also used to coordinate command processing and builder runs within that thread.
Exceptions
error::Fatalwhen a deadlock due to such a recursive call can be detected

Definition at line 462 of file steam-dispatcher.cpp.

◆ endRunningLoopState()

void endRunningLoopState ( )
private

clean-up when leaving the session loop thread. This function is hooked up in to the termination callback, and is in fact the only one to delete the loop PImpl. We take the (outer) lock on SteamDispatcher to ensure no one commits anything to the DispatcherLoop object while being deleted. The call itself, while technically originating from within DispatcherLoop::runSessionThread(), relies solely on stack based context data and is a tail call.

Definition at line 380 of file steam-dispatcher.cpp.

Referenced by SteamDispatcher::start().

+ Here is the caller graph for this function:
+ Inheritance diagram for SteamDispatcher:
+ Collaboration diagram for SteamDispatcher:

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