pass compiler and starts OK without doing anything

This commit is contained in:
Fischlurch 2008-12-04 04:21:02 +01:00 committed by Christian Thaeter
parent 75b97ff9dd
commit 41f9f54907
12 changed files with 65 additions and 30 deletions

View file

@ -24,15 +24,18 @@
#include "backend/enginefacade.hpp" #include "backend/enginefacade.hpp"
#include "common/singleton.hpp" #include "common/singleton.hpp"
#include <string>
namespace backend { namespace backend {
using std::string;
using lumiera::Subsys; using lumiera::Subsys;
class EngineSubsysDescriptor class EngineSubsysDescriptor
: public Subsys : public Subsys
{ {
operator string () { return "Engine"; } operator string () const { return "Engine"; }
bool bool
shouldStart (lumiera::Option&) shouldStart (lumiera::Option&)

View file

@ -24,15 +24,17 @@
#include "backend/netnodefacade.hpp" #include "backend/netnodefacade.hpp"
#include "common/singleton.hpp" #include "common/singleton.hpp"
#include <string>
namespace backend { namespace backend {
using std::string;
using lumiera::Subsys; using lumiera::Subsys;
class NetNodeSubsysDescriptor class NetNodeSubsysDescriptor
: public Subsys : public Subsys
{ {
operator string () { return "Renderfarm node"; } operator string () const { return "Renderfarm node"; }
bool bool
shouldStart (lumiera::Option&) shouldStart (lumiera::Option&)

View file

@ -24,15 +24,18 @@
#include "backend/scriptrunnerfacade.hpp" #include "backend/scriptrunnerfacade.hpp"
#include "common/singleton.hpp" #include "common/singleton.hpp"
#include <string>
namespace backend { namespace backend {
using std::string;
using lumiera::Subsys; using lumiera::Subsys;
class ScriptRunnerSubsysDescriptor class ScriptRunnerSubsysDescriptor
: public Subsys : public Subsys
{ {
operator string () { return "Script runner"; } operator string () const { return "Script runner"; }
bool bool
shouldStart (lumiera::Option&) shouldStart (lumiera::Option&)

View file

@ -41,7 +41,7 @@
#include <map> #include <map>
#include <set> #include <set>
#include <string> #include <string>
#include <boost/function.hpp> #include <tr1/functional>
#include <boost/noncopyable.hpp> #include <boost/noncopyable.hpp>
#include "common/util.hpp" #include "common/util.hpp"
@ -50,7 +50,7 @@
namespace lumiera { namespace lumiera {
using boost::noncopyable; using boost::noncopyable;
using boost::function; using std::tr1::function;
using util::contains; using util::contains;
using std::string; using std::string;

View file

@ -195,7 +195,11 @@ namespace lumiera {
try try
{ {
if (subsystems_) subsystems_->shutdownAll(); if (subsystems_)
{
subsystems_->triggerEmergency(true);
subsystems_->shutdownAll();
}
return maybeWait (); return maybeWait ();
} }
catch (...) catch (...)

View file

@ -24,7 +24,6 @@
//TODO: Lumiera header includes// //TODO: Lumiera header includes//
#include "lumiera/lumiera.h"
#include "lumiera/config.h" #include "lumiera/config.h"
//TODO: internal/static forward declarations// //TODO: internal/static forward declarations//

View file

@ -24,15 +24,18 @@
#include "gui/guifacade.hpp" #include "gui/guifacade.hpp"
#include "common/singleton.hpp" #include "common/singleton.hpp"
#include <string>
namespace gui { namespace gui {
using std::string;
using lumiera::Subsys; using lumiera::Subsys;
class GuiSubsysDescriptor class GuiSubsysDescriptor
: public Subsys : public Subsys
{ {
operator string () { return "Lumiera GTK GUI"; } operator string () const { return "Lumiera GTK GUI"; }
bool bool
shouldStart (lumiera::Option&) shouldStart (lumiera::Option&)

View file

@ -29,7 +29,6 @@
#include "lumiera/lumiera.h"
#include "lumiera/plugin.h" #include "lumiera/plugin.h"
#include "lumiera/interfaceregistry.h" #include "lumiera/interfaceregistry.h"

View file

@ -53,8 +53,8 @@ namespace lumiera {
bool bool
Subsys::isRunning() Subsys::isRunning()
{ {
UNIMPLEMENTED ("maintain isRunning flag in a threadsafe manner"); TODO ("maintain isRunning flag in a threadsafe manner");
return false; return true;
} }

View file

@ -48,7 +48,7 @@
#include "lumiera/option.hpp" #include "lumiera/option.hpp"
#include <boost/noncopyable.hpp> #include <boost/noncopyable.hpp>
#include <boost/tr1/functional.hpp> #include <tr1/functional>
//#include <boost/scoped_ptr.hpp> //#include <boost/scoped_ptr.hpp>
//#include <string> //#include <string>
#include <vector> #include <vector>
@ -78,7 +78,7 @@ namespace lumiera {
virtual ~Subsys(); virtual ~Subsys();
/** a human readable name */ /** a human readable name */
virtual operator string () =0; virtual operator string () const =0;
/** define a dependency to another Subsys /** define a dependency to another Subsys
@ -112,6 +112,10 @@ namespace lumiera {
* terminate at any point without further notice*/ * terminate at any point without further notice*/
bool isRunning(); bool isRunning();
const std::vector<Subsys*>
getPrerequisites () { return prereq_; }
private: private:
std::vector<Subsys*> prereq_; std::vector<Subsys*> prereq_;

View file

@ -29,7 +29,7 @@
#include "lumiera/subsys.hpp" #include "lumiera/subsys.hpp"
#include "common/multithread.hpp" #include "common/multithread.hpp"
#include <boost/tr1/functional.hpp> #include <tr1/functional>
#include <vector> #include <vector>
@ -37,6 +37,7 @@ namespace lumiera {
using std::tr1::bind; using std::tr1::bind;
using std::tr1::function; using std::tr1::function;
using std::tr1::placeholders::_1;
using std::vector; using std::vector;
using util::cStr; using util::cStr;
using util::isnil; using util::isnil;
@ -44,6 +45,13 @@ namespace lumiera {
using util::for_each; using util::for_each;
using util::removeall; using util::removeall;
namespace {
function<bool(Subsys*)>
isRunning() {
return bind (&Subsys::isRunning, _1);
}
}
/***************************************************************************** /*****************************************************************************
* Implementation helper for managing execution of a collection of subsystems, * Implementation helper for managing execution of a collection of subsystems,
@ -81,15 +89,18 @@ namespace lumiera {
class SubsystemRunner class SubsystemRunner
{ {
Option& opts_; Option& opts_;
volatile bool emergency_;
vector<Subsys*> running_; vector<Subsys*> running_;
function<void(Subsys&)> start_, function<void(Subsys*)> start_,
killIt_; killIt_;
public: public:
SubsystemRunner (Option& opts) SubsystemRunner (Option& opts)
: opts_(opts) : opts_(opts)
, emergency_(false)
, start_(bind (&SubsystemRunner::triggerStartup, this,_1)) , start_(bind (&SubsystemRunner::triggerStartup, this,_1))
, killIt_(bind (&Subsys::triggerShutdown, _1)) , killIt_(bind (&Subsys::triggerShutdown, _1))
{ } { }
@ -112,13 +123,16 @@ namespace lumiera {
for_each (running_, killIt_); for_each (running_, killIt_);
} }
void bool
wait () wait ()
{ {
//Lock(*this).wait (&SubsystemRunner::allDead); //Lock(*this).wait (&SubsystemRunner::allDead);
return isEmergencyExit(); return isEmergencyExit();
} }
bool isEmergencyExit () { return emergency_; }
void triggerEmergency (bool cond) { emergency_ |= cond; }
private: private:
@ -129,17 +143,17 @@ namespace lumiera {
ASSERT (susy); ASSERT (susy);
INFO (operate, "Starting subsystem \"%s\"", cStr(*susy)); INFO (operate, "Starting subsystem \"%s\"", cStr(*susy));
for_each (susy->prereq_, start_); for_each (susy->getPrerequisites(), start_);
bool started = susy.start (opts_, bind (&SubsystemRunner::sigTerm, this, susy, _1)); bool started = susy->start (opts_, bind (&SubsystemRunner::sigTerm, this, susy, _1));
if (started && !susy.isRunning()) if (started && !susy->isRunning())
{ {
throw error::Logic("Subsystem "+susy+" failed to start"); throw error::Logic("Subsystem "+string(*susy)+" failed to start");
} }
if (!and_all (susy->prereq_, isRunning_)) if (!and_all (susy->getPrerequisites(), isRunning() ))
{ {
susy->triggerShutdown(); susy->triggerShutdown();
throw error::Logic("Unable to start all prerequisites of Subsystem "+susy); throw error::Logic("Unable to start all prerequisites of Subsystem "+string(*susy));
} } } }
void void
@ -147,8 +161,9 @@ namespace lumiera {
{ {
ASSERT (susy); ASSERT (susy);
//Lock guard (*this); //Lock guard (*this);
ERROR_IF (susy.isRunning(), lumiera, "Subsystem '%s' signals termination, " triggerEmergency(problem);
"without resetting running state", cStr(susy)); ERROR_IF (susy->isRunning(), lumiera, "Subsystem '%s' signals termination, "
"without resetting running state", cStr(*susy));
removeall (running_, susy); removeall (running_, susy);
shutdownAll(); shutdownAll();
//guard.notify(); //guard.notify();

View file

@ -24,16 +24,19 @@
#include "proc/facade.hpp" #include "proc/facade.hpp"
#include "common/singleton.hpp" #include "common/singleton.hpp"
#include <string>
namespace proc { namespace proc {
using std::string;
using lumiera::Subsys; using lumiera::Subsys;
class BuilderSubsysDescriptor class BuilderSubsysDescriptor
: public Subsys : public Subsys
{ {
operator string () { return "Builder"; } operator string () const { return "Builder"; }
bool bool
shouldStart (lumiera::Option&) shouldStart (lumiera::Option&)
@ -62,7 +65,7 @@ namespace proc {
class SessionSubsysDescriptor class SessionSubsysDescriptor
: public Subsys : public Subsys
{ {
operator string () { return "Session"; } operator string () const { return "Session"; }
bool bool
shouldStart (lumiera::Option&) shouldStart (lumiera::Option&)