Integration: Thread/sync, GUI-Plugin invoked in separate thread

This commit is contained in:
Fischlurch 2009-01-03 16:05:04 +01:00
parent 683e1dabe1
commit edb01ec8c6
7 changed files with 26 additions and 24 deletions

View file

@ -27,6 +27,7 @@
#include "lib/error.hpp"
#include "lib/singleton.hpp"
#include "lib/functorutil.hpp"
#include "lib/thread-wrapper.hpp"
#include "common/instancehandle.hpp"
#include <boost/scoped_ptr.hpp>
@ -45,6 +46,7 @@ namespace gui {
using util::dispatchSequenced;
using lib::Sync;
using lib::RecursiveLock_NoWait;
using lib::Thread;
@ -60,17 +62,18 @@ namespace gui {
: theGUI_("lumieraorg_Gui", 1, 1, "lumieraorg_GuiStarterPlugin") // load GuiStarterPlugin
{
ASSERT (theGUI_);
if (!kickOff (terminationHandle))
Thread ("GUI-Main", bind (&GuiRunner::kickOff, this, terminationHandle));
if (lumiera_error_peek())
throw lumiera::error::Fatal("failed to bring up GUI",lumiera_error());
}
~GuiRunner () { }
bool kickOff (Subsys::SigTerm& terminationHandle)
void kickOff (Subsys::SigTerm& terminationHandle)
{
return theGUI_->kickOff (reinterpret_cast<void*> (&terminationHandle))
&& !lumiera_error_peek();
theGUI_->kickOff (reinterpret_cast<void*> (&terminationHandle));
}
};
@ -81,6 +84,7 @@ namespace gui {
scoped_ptr<GuiRunner> facade (0);
class GuiSubsysDescriptor
: public lumiera::Subsys,
public Sync<RecursiveLock_NoWait>
@ -123,10 +127,10 @@ namespace gui {
bool
checkRunningState () throw()
{
Lock guard (this);
return (facade);
}
void
closeGuiModule (lumiera::Error *)
{

View file

@ -177,6 +177,7 @@ namespace lumiera {
ASSERT (susy);
Lock sync (this);
triggerEmergency(problem);
INFO (operate, "Subsystem '%s' terminated.", cStr(*susy));
ERROR_IF (susy->isRunning(), lumiera, "Subsystem '%s' signals termination, "
"without resetting running state", cStr(*susy));
removeall (running_, susy);

View file

@ -91,7 +91,7 @@ namespace gui {
* @internal this function is invoked automatically during the GUI
* loading and startup process. Don't call it manually.
*/
virtual bool kickOff (lumiera::Subsys::SigTerm&) =0;
virtual void kickOff (lumiera::Subsys::SigTerm&) =0;
protected:
@ -100,7 +100,7 @@ namespace gui {
/** interface of the GuiStarterPlugin */
LUMIERA_INTERFACE_DECLARE (lumieraorg_Gui, 1,
LUMIERA_INTERFACE_SLOT (bool, kickOff, (void*))
LUMIERA_INTERFACE_SLOT (void, kickOff, (void*))
);

View file

@ -75,7 +75,7 @@ namespace gui {
: public GuiFacade
{
bool kickOff (Subsys::SigTerm& terminationHandle)
void kickOff (Subsys::SigTerm& terminationHandle)
{
cout << " *** Ha Ha Ha\n"
<< " this is the GuiStarterPlugin speaking!\n"
@ -83,7 +83,6 @@ namespace gui {
<< " but actually nothing happens!!!!!!!!!!!!!!\n\n";
terminationHandle(0); // signal immediate shutdown without error
return false;
}
};
@ -179,9 +178,9 @@ extern "C" { /* ================== define an lumieraorg_Gui instance ===========
, NULL /* on open */
, NULL /* on close */
, LUMIERA_INTERFACE_INLINE (kickOff, "\255\142\006\244\057\170\152\312\301\372\220\323\230\026\200\065",
bool, (void* termSig),
void, (void* termSig),
{
return gui::facade_().kickOff (
gui::facade_().kickOff (
*reinterpret_cast<Subsys::SigTerm *> (termSig));
}
)

View file

@ -21,8 +21,8 @@
*/
#ifndef LUMIERA_THREADWRAPPER_H
#define LUMIERA_THREADWRAPPER_H
#ifndef LIB_THREADWRAPPER_H
#define LIB_THREADWRAPPER_H
#include "include/nobugcfg.h"
@ -36,14 +36,11 @@ extern "C" {
#include <boost/noncopyable.hpp>
namespace lumiera {
namespace lib {
using std::tr1::bind;
using std::tr1::function;
using std::tr1::placeholders::_1;
using lib::Sync;
using lib::NonrecursiveLock_Waitable;
using lumiera::Literal;
/**
@ -106,7 +103,7 @@ namespace lumiera {
);
if (!res)
throw error::State("failed to create new thread.");
throw lumiera::error::State("failed to create new thread.");
// make sure the new thread had the opportunity to take the Operation
// prior to leaving and thereby possibly destroying this local context
@ -116,5 +113,5 @@ namespace lumiera {
} // namespace lumiera
} // namespace lib
#endif

View file

@ -43,6 +43,7 @@ using util::cStr;
using test::Test;
using lib::Sync;
using lib::RecursiveLock_Waitable;
using lib::Thread;
namespace lumiera {

View file

@ -34,8 +34,8 @@ using test::Test;
namespace lumiera {
namespace test {
namespace lib {
namespace test {
namespace { // private test classes and data...
@ -86,7 +86,7 @@ namespace lumiera {
* lumiera::Thread wrapper for binding to an arbitrary operation
* and passing the appropriate context.
*
* @see lumiera::Thread
* @see lib::Thread
* @see threads.h
*/
class ThreadWrapper_test : public Test
@ -114,4 +114,4 @@ namespace lumiera {
} // namespace test
} // namespace lumiera
} // namespace lib