GUI-start: replace the chained termination functors with a lambda
This is the solution I found out when implementing the ProcDispatcher; looks way more readable to me
This commit is contained in:
parent
df84de2e81
commit
1bd3eabe7d
2 changed files with 15 additions and 19 deletions
|
|
@ -30,7 +30,6 @@
|
|||
#include "common/instancehandle.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
|
||||
|
|
@ -38,11 +37,8 @@ namespace gui {
|
|||
|
||||
using std::string;
|
||||
using std::unique_ptr;
|
||||
using std::bind;
|
||||
using std::placeholders::_1;
|
||||
using lumiera::Subsys;
|
||||
using lumiera::InstanceHandle;
|
||||
using util::dispatchSequenced;
|
||||
using lib::Sync;
|
||||
using lib::RecursiveLock_NoWait;
|
||||
|
||||
|
|
@ -103,15 +99,20 @@ namespace gui {
|
|||
}
|
||||
|
||||
bool
|
||||
start (lumiera::Option&, Subsys::SigTerm termination) override
|
||||
start (lumiera::Option&, Subsys::SigTerm termNotification) override
|
||||
{
|
||||
Lock guard (this);
|
||||
if (facade) return false; // already started
|
||||
if (facade)
|
||||
return false; // already started
|
||||
|
||||
facade.reset ( // trigger loading of the GuiStarterPlugin...
|
||||
new GuiRunner (
|
||||
[=] (string* problemMessage)
|
||||
{ // will be invoked when the UI thread exits
|
||||
closeGuiModule();
|
||||
termNotification(problemMessage);
|
||||
}));
|
||||
|
||||
facade.reset (
|
||||
new GuiRunner ( // trigger loading load the GuiStarterPlugin...
|
||||
dispatchSequenced( closeOnTermination_ // on termination call this->closeGuiModule(*) first
|
||||
, termination))); //...followed by invoking the given termSignal
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -140,7 +141,7 @@ namespace gui {
|
|||
|
||||
|
||||
void
|
||||
closeGuiModule (std::string *)
|
||||
closeGuiModule ()
|
||||
{
|
||||
Lock guard (this);
|
||||
if (!facade)
|
||||
|
|
@ -153,14 +154,11 @@ namespace gui {
|
|||
}
|
||||
|
||||
|
||||
Subsys::SigTerm closeOnTermination_;
|
||||
|
||||
public:
|
||||
GuiSubsysDescriptor()
|
||||
: closeOnTermination_ (bind (&GuiSubsysDescriptor::closeGuiModule, this, _1))
|
||||
{ }
|
||||
GuiSubsysDescriptor() { }
|
||||
|
||||
~GuiSubsysDescriptor()
|
||||
~GuiSubsysDescriptor()
|
||||
{
|
||||
if (facade)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -65,14 +65,12 @@ extern "C" {
|
|||
#include "common/interface-descriptor.h"
|
||||
}
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
|
||||
|
||||
using std::string;
|
||||
using backend::Thread;
|
||||
using std::bind;
|
||||
using lumiera::Subsys;
|
||||
using lumiera::error::LUMIERA_ERROR_STATE;
|
||||
using gui::LUMIERA_INTERFACE_INAME(lumieraorg_Gui, 1);
|
||||
|
|
@ -149,7 +147,7 @@ namespace gui {
|
|||
{
|
||||
try
|
||||
{
|
||||
Thread ("GUI-Main", bind (&runGUI, terminationHandle));
|
||||
Thread {"GUI-Main", [&]() { runGUI(terminationHandle); }};
|
||||
return true; // if we reach this line...
|
||||
}
|
||||
catch(...)
|
||||
|
|
|
|||
Loading…
Reference in a new issue