change error notification at subsystem shutdown to use just a string*
(this allows to memoize the error message and call the termination handler outside the catch block)
This commit is contained in:
parent
3da9586824
commit
b6fb135398
6 changed files with 17 additions and 6 deletions
|
|
@ -136,7 +136,7 @@ namespace gui {
|
|||
|
||||
|
||||
void
|
||||
closeGuiModule (lumiera::Error *)
|
||||
closeGuiModule (std::string *)
|
||||
{
|
||||
Lock guard (this);
|
||||
if (!facade)
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ namespace lumiera {
|
|||
: private noncopyable
|
||||
{
|
||||
public:
|
||||
typedef function<void(Error*)> SigTerm;
|
||||
typedef function<void(string*)> SigTerm;
|
||||
|
||||
virtual ~Subsys();
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include <tr1/functional>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace lumiera {
|
||||
|
|
@ -39,6 +40,7 @@ namespace lumiera {
|
|||
using std::tr1::function;
|
||||
using std::tr1::placeholders::_1;
|
||||
using std::vector;
|
||||
using std::string;
|
||||
using util::cStr;
|
||||
using util::isnil;
|
||||
using util::and_all;
|
||||
|
|
@ -172,12 +174,13 @@ namespace lumiera {
|
|||
} }
|
||||
|
||||
void
|
||||
sigTerm (Subsys* susy, Error* problem) ///< called from subsystem on termination
|
||||
sigTerm (Subsys* susy, string* problem) ///< called from subsystem on termination
|
||||
{
|
||||
ASSERT (susy);
|
||||
Lock sync (this);
|
||||
triggerEmergency(problem);
|
||||
triggerEmergency(!isnil (problem));
|
||||
INFO (operate, "Subsystem '%s' terminated.", cStr(*susy));
|
||||
WARN_IF (!isnil(problem), operate, "Irregular shutdown caused by: %s", cStr(*problem));
|
||||
ERROR_IF (susy->isRunning(), lumiera, "Subsystem '%s' signals termination, "
|
||||
"without resetting running state", cStr(*susy));
|
||||
removeall (running_, susy);
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ namespace gui {
|
|||
|
||||
~GuiLifecycle ()
|
||||
{
|
||||
reportOnTermination_(0); /////////TODO: pass on error information
|
||||
reportOnTermination_(&error_); // inform main thread that the GUI has been shut down.
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -60,6 +60,13 @@ namespace util {
|
|||
return !pContainer || pContainer->empty();
|
||||
}
|
||||
|
||||
template <class CONT>
|
||||
inline bool
|
||||
isnil (CONT* pContainer)
|
||||
{
|
||||
return !pContainer || pContainer->empty();
|
||||
}
|
||||
|
||||
inline bool
|
||||
isnil (const char* pCStr)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -165,13 +165,14 @@ namespace lumiera {
|
|||
lumiera_error(); // reset error state....
|
||||
// Note: in real life this actually
|
||||
// would be an catched exception!
|
||||
string problemReport (problemIndicator.what());
|
||||
|
||||
{
|
||||
Lock guard (this);
|
||||
isUp_ = false;
|
||||
|
||||
INFO (test, "thread %s terminates.", cStr(*this));
|
||||
termination ("true"==runSpec? 0 : &problemIndicator);
|
||||
termination ("true"==runSpec? 0 : &problemReport);
|
||||
} }
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue