Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
DispatcherLoop Class Reference

Description

PImpl within SteamDispatcher to implement the Session Loop Thread.

During the lifetime of this object...

  • the SessionCommandService is offered to enqueue commands
  • the Session Loop thread dispatches commands and triggers the Builder
    See also
    DispatcherLooper_test

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

Public Member Functions

template<typename FUN >
 DispatcherLoop (FUN &&atExit)
 start the session loop thread
 
 ~DispatcherLoop ()
 
void activateCommandProecssing ()
 
void deactivateCommandProecssing ()
 
void requestStop () noexcept
 
void awaitStateProcessed () const
 
size_t size () const
 
void enqueue (Command &&cmd) override
 
void clear () override
 
- Public Member Functions inherited from CommandDispatch
virtual ~CommandDispatch ()
 this is an interface
 

Private Types

using ServiceHandle = lib::DependInject< SessionCommandService >::ServiceInstance<>
 
using Launch = lib::ThreadHookable::Launch
 

Private Member Functions

void runSessionThread ()
 any operation running in the Session thread is started from here.
 
void awaitAction ()
 
void updateState ()
 
bool isStateSynched () const
 
void processCommands ()
 
void startBuilder ()
 

Private Attributes

ServiceHandle commandService_
 manage the primary public Session interface
 
SyncBarrier init_
 
CommandQueue queue_
 
string error_
 
Looper looper_
 
ThreadHookable thread_
 

Additional Inherited Members

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

Constructor & Destructor Documentation

◆ DispatcherLoop()

template<typename FUN >
DispatcherLoop ( FUN &&  atExit)
inline

start the session loop thread

Parameters
notificationcallback to invoke on thread termination
Remarks
in theory this ctor could block, since it waits for the thread actually to get operational and it waits for the SessionCommand interface to be opened. The latter better should not run into any obstacles, because in case it does, the main application thread will be deadlocked on startup. Such might happen indirectly, when something depends on "the Session"

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

References IterQueue< TY >::empty(), and DispatcherLoop::queue_.

+ Here is the call graph for this function:

◆ ~DispatcherLoop()

~DispatcherLoop ( )
inline

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

References DispatcherLoop::commandService_, ERROR_LOG_AND_IGNORE, DependInject< SRV >::ServiceInstance< IMP >::shutdown(), and DispatcherLoop::thread_.

+ Here is the call graph for this function:

Member Typedef Documentation

◆ ServiceHandle

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

◆ Launch

using Launch = lib::ThreadHookable::Launch
private

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

Member Function Documentation

◆ activateCommandProecssing()

void activateCommandProecssing ( )
inline

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

References Looper::enableProcessing(), and DispatcherLoop::looper_.

+ Here is the call graph for this function:

◆ deactivateCommandProecssing()

void deactivateCommandProecssing ( )
inline

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

References Looper::enableProcessing(), and DispatcherLoop::looper_.

+ Here is the call graph for this function:

◆ requestStop()

void requestStop ( )
inlinenoexcept

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

References DispatcherLoop::commandService_, DispatcherLoop::looper_, DependInject< SRV >::ServiceInstance< IMP >::shutdown(), and Looper::triggerShutdown().

+ Here is the call graph for this function:

◆ awaitStateProcessed()

void awaitStateProcessed ( ) const
inline

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

References DispatcherLoop::isStateSynched().

+ Here is the call graph for this function:

◆ size()

size_t size ( ) const
inline

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

References DispatcherLoop::queue_, and IterQueue< TY >::size().

+ Here is the call graph for this function:

◆ enqueue()

void enqueue ( Command &&  cmd)
inlineoverridevirtual

Implements CommandDispatch.

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

References CommandQueue::feed(), and DispatcherLoop::queue_.

+ Here is the call graph for this function:

◆ clear()

void clear ( )
inlineoverridevirtual

Implements CommandDispatch.

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

References CommandQueue::clear(), and DispatcherLoop::queue_.

+ Here is the call graph for this function:

◆ runSessionThread()

void runSessionThread ( )
inlineprivate

any operation running in the Session thread is started from here.

When this loop terminates, the »session subsystem« shuts down.

Note
the callback notifyEnd is typically bound to invoke SteamDispatcher::endRunningLoopState().

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

References DispatcherLoop::awaitAction(), DispatcherLoop::error_, DispatcherLoop::init_, Looper::isDying(), Looper::isWorking(), DispatcherLoop::looper_, lumiera_error(), DispatcherLoop::processCommands(), Looper::runBuild(), Looper::shallLoop(), DispatcherLoop::startBuilder(), SyncBarrier::sync(), and DispatcherLoop::updateState().

+ Here is the call graph for this function:

◆ awaitAction()

void awaitAction ( )
inlineprivate

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

References Looper::getTimeout(), and DispatcherLoop::looper_.

Referenced by DispatcherLoop::runSessionThread().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateState()

void updateState ( )
inlineprivate

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

References Sync< RecursiveLock_Waitable >::getMonitor(), Looper::isDisabled(), DispatcherLoop::looper_, Looper::markStateProcessed(), and Monitor< IMPL >::notify_all().

Referenced by DispatcherLoop::runSessionThread().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isStateSynched()

bool isStateSynched ( ) const
inlineprivate

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

References Looper::hasPendingChanges(), DispatcherLoop::looper_, and DispatcherLoop::thread_.

Referenced by DispatcherLoop::awaitStateProcessed().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processCommands()

void processCommands ( )
inlineprivate

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

References cStr(), IterQueue< TY >::empty(), IterQueue< TY >::pop(), DispatcherLoop::queue_, and util::startsWith().

Referenced by DispatcherLoop::runSessionThread().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ startBuilder()

void startBuilder ( )
inlineprivate

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

Referenced by DispatcherLoop::runSessionThread().

+ Here is the caller graph for this function:

Member Data Documentation

◆ commandService_

ServiceHandle commandService_
private

manage the primary public Session interface

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

Referenced by DispatcherLoop::~DispatcherLoop(), and DispatcherLoop::requestStop().

◆ init_

SyncBarrier init_
private

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

Referenced by DispatcherLoop::runSessionThread().

◆ queue_

◆ error_

string error_
private

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

Referenced by DispatcherLoop::runSessionThread().

◆ looper_

◆ thread_

ThreadHookable thread_
private
+ Inheritance diagram for DispatcherLoop:
+ Collaboration diagram for DispatcherLoop:

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