diff --git a/src/common/subsys.hpp b/src/common/subsys.hpp index 6b9257532..67276f39e 100644 --- a/src/common/subsys.hpp +++ b/src/common/subsys.hpp @@ -76,7 +76,7 @@ namespace lumiera { virtual ~Subsys(); /** a human readable name */ - virtual operator string () const =0; + virtual operator string() const =0; /** define a dependency to another Subsys @@ -111,11 +111,11 @@ namespace lumiera { * the SigTerm passed to #start must be invoked. * @note called within a locked context (barrier) * @warning must not block nor throw. */ - virtual void triggerShutdown () noexcept =0; + virtual void triggerShutdown() noexcept =0; const std::vector - getPrerequisites () { return prereq_; } + getPrerequisites() { return prereq_; } private: diff --git a/src/proc/control/proc-dispatcher.cpp b/src/proc/control/proc-dispatcher.cpp index dc691abd2..e86b59ee4 100644 --- a/src/proc/control/proc-dispatcher.cpp +++ b/src/proc/control/proc-dispatcher.cpp @@ -51,6 +51,7 @@ namespace control { { bool canDispatch_{false}; bool blocked_ {false}; + bool mustHalt_ {false}; unique_ptr commandService_; @@ -68,8 +69,8 @@ namespace control { { try { Lock sync(this); - commandService_.reset(); - this->join(); + commandService_.reset(); // redundant call, ensure the session interface is reliably closed + this->join(); // block until the loop thread terminates and is reaped INFO (session, "Proc-Dispatcher stopped."); } ERROR_LOG_AND_IGNORE(session, "Stopping the Proc-Dispatcher"); @@ -110,6 +111,15 @@ namespace control { return 0; } + void + requestStop() noexcept + { + Lock sync(this); + commandService_.reset(); // closes Session interface + mustHalt_ = true; + UNIMPLEMENTED("*must* notify loop thread"); /////////////////TODO really? + } + private: void run (Subsys::SigTerm sigTerm) @@ -117,7 +127,7 @@ namespace control { string errorMsg; try { - TODO ("actually do something in the loop"); + TODO ("actually do something in the loop"); /////////////////////////////////////////TODO *** THIS NEXT TO IMPLEMENT !!!! *** sleep(2); } catch (lumiera::Error& problem) @@ -173,12 +183,17 @@ namespace control { } - /** */ + /** signal to the loop thread that it needs to terminate. + * @warning dangerous operation; must not block nor throw + * + * @todo need to re-check the logic, once the loop is fully implemented; ensure there is nothing on this call path that can block or throw!!! + */ void - ProcDispatcher::requestStop() + ProcDispatcher::requestStop() noexcept { Lock sync(this); - UNIMPLEMENTED ("trigger shutdown into the dispacher loop thread"); + if (runningLoop_) + runningLoop_->requestStop(); } diff --git a/src/proc/control/proc-dispatcher.hpp b/src/proc/control/proc-dispatcher.hpp index 7cf02ab4a..8ea73de2e 100644 --- a/src/proc/control/proc-dispatcher.hpp +++ b/src/proc/control/proc-dispatcher.hpp @@ -72,7 +72,7 @@ namespace control { bool start (Subsys::SigTerm); bool isRunning(); - void requestStop(); + void requestStop() noexcept; void activate(); void deactivate(); diff --git a/src/proc/facade.cpp b/src/proc/facade.cpp index 8d690deed..b36487031 100644 --- a/src/proc/facade.cpp +++ b/src/proc/facade.cpp @@ -81,7 +81,7 @@ namespace proc { class SessionSubsystem : public Subsys { - operator string () const { return "Session"; } + operator string() const { return "Session"; } /** @remarks there is no need explicitly to start the session core, * since it will usually be pulled up as prerequisite */ @@ -98,13 +98,13 @@ namespace proc { } void - triggerShutdown () noexcept override + triggerShutdown() noexcept override { ProcDispatcher::instance().requestStop(); } bool - checkRunningState () noexcept override + checkRunningState() noexcept override { return ProcDispatcher::instance().isRunning(); } @@ -115,7 +115,7 @@ namespace proc { class PlayOutSubsysDescriptor : public Subsys { - operator string () const { return "PlayOut"; } + operator string() const { return "PlayOut"; } /** determine, if any output system is required to start up explicitly. * Moreover, extract configuration variations for specific kinds of output @@ -142,14 +142,14 @@ namespace proc { void - triggerShutdown () noexcept override + triggerShutdown() noexcept override { play::OutputDirector::instance().triggerDisconnect (completedSignal_); } bool - checkRunningState () noexcept override + checkRunningState() noexcept override { return play::OutputDirector::instance().isOperational(); } diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index c54fcc413..83306912f 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -508,7 +508,7 @@ - + @@ -523,11 +523,14 @@ + + + - - + + @@ -10989,8 +10992,8 @@ - - + + @@ -11002,14 +11005,34 @@ - + + - + + + + + + + + + + + + + + + + + + + +