// CORBA Servant Launcher
QMutex _GUIMutex ;
+ QWaitCondition _ServerLaunch;
+ _GUIMutex.lock(); // to block Launch server thread until wait(mutex)
Session_ServerLauncher* myServerLauncher
- = new Session_ServerLauncher(argc, argv, orb, poa, &_GUIMutex);
- myServerLauncher->Init();
+ = new Session_ServerLauncher(argc, argv, orb, poa, &_GUIMutex, &_ServerLaunch);
+ myServerLauncher->start();
+
+ MESSAGE("waiting wakeAll()");
+ _ServerLaunch.wait(&_GUIMutex); // to be reseased by Launch server thread when ready:
+ // atomic operation lock - unlock on mutex
+ // unlock mutex: serverThread runs, calls _ServerLaunch->wakeAll()
+ // this thread wakes up, and lock mutex
INFOS("Session activated, Launch IAPP...");
- _GUIMutex.lock();
int qappArgc = 1;
QApplication *_qappl = new QApplication(qappArgc, argv );
INFOS("creation QApplication");
char ** argv,
CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa,
- QMutex *GUIMutex)
+ QMutex *GUIMutex,
+ QWaitCondition *ServerLaunch)
{
_argc = argc;
_argv = argv;
_orb = CORBA::ORB::_duplicate(orb);
_root_poa = PortableServer::POA::_duplicate(poa);
_GUIMutex = GUIMutex;
+ _ServerLaunch = ServerLaunch;
}
//=============================================================================
*/
//=============================================================================
-void Session_ServerLauncher::Init()
+void Session_ServerLauncher::run()
{
+ MESSAGE("Session_ServerLauncher::run");
+ _GUIMutex->lock(); // lock released by calling thread when ready: wait(mutex)
+ MESSAGE("Server Launcher thread free to go...");
+ _GUIMutex->unlock();
+
CheckArgs();
ActivateAll();
+
+ _ServerLaunch->wakeAll();
+ _orb->run(); // this thread wait, during omniORB process events
}
//=============================================================================
void Session_ServerLauncher::ActivateAll()
{
- _GUIMutex->lock(); // to block server threads until wait(mutex)
-
list<ServArg>::iterator itServ;
for (itServ = _argServToLaunch.begin(); itServ !=_argServToLaunch.end(); itServ++)
{
argv[i+1] = _argv[(*itServ)._firstArg + i];
}
Session_ServerThread* aServerThread
- = new Session_ServerThread(argc, argv, _orb,_root_poa,_GUIMutex,&_ServerLaunch);
+ = new Session_ServerThread(argc, argv, _orb,_root_poa,_GUIMutex);
_serverThreads.push_back(aServerThread);
- aServerThread->start();
- MESSAGE("waiting wakeAll()");
- _ServerLaunch.wait(_GUIMutex); // to be reseased by serverThread when ready:
- // atomic operation lock - unlock on mutex
- // unlock mutex: serverThread runs, calls _ServerLaunch->wakeAll()
- // this thread wakes up, and lock mutex
+ aServerThread->Init();
}
// Always launch Session Server
char** argv = new char*[argc];
argv[0] = "Session";
Session_ServerThread* aServerThread
- = new Session_ServerThread(argc, argv, _orb,_root_poa,_GUIMutex,&_ServerLaunch);
+ = new Session_ServerThread(argc, argv, _orb,_root_poa,_GUIMutex);
_serverThreads.push_back(aServerThread);
- aServerThread->start();
- _ServerLaunch.wait(_GUIMutex); // to be reseased by serverThread when ready
- // atomic operation lock - unlock on mutex
- // unlock mutex: serverThread runs, calls _ServerLaunch->wakeAll()
- // this thread wakes up, and lock mutex
-
- _GUIMutex->unlock(); // release mutex for Qt main Thread
+ aServerThread->Init();
}
#include <list>
#include <vector>
#include <string>
+#include <qthread.h>
#include <qwaitcondition.h>
using namespace std;
_servType(servType),_firstArg(firstArg),_lastArg(lastArg)
{}
-class Session_ServerLauncher
+class Session_ServerLauncher: public QThread
{
public:
Session_ServerLauncher();
char ** argv,
CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa,
- QMutex *GUIMutex);
- virtual ~Session_ServerLauncher();;
- void Init();
+ QMutex *GUIMutex,
+ QWaitCondition *ServerLaunch);
+ virtual ~Session_ServerLauncher();
+ void run();
protected:
void CheckArgs();
CORBA::ORB_var _orb;
PortableServer::POA_var _root_poa;
QMutex* _GUIMutex;
- QWaitCondition _ServerLaunch;
+ QWaitCondition *_ServerLaunch;
list<ServArg> _argServToLaunch;
vector<string> _argCopy;
list<Session_ServerThread*> _serverThreads;
char ** argv,
CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa,
- QMutex *GUIMutex,
- QWaitCondition *ServerLaunch)
+ QMutex *GUIMutex)
{
MESSAGE("Session_ServerThread Constructor " << argv[0]);
_argc = argc;
_orb = CORBA::ORB::_duplicate(orb);
_root_poa = PortableServer::POA::_duplicate(poa);
_GUIMutex = GUIMutex;
- _ServerLaunch = ServerLaunch;
_servType =-1;
_NS = new SALOME_NamingService(_orb); // one instance per server to limit
// multi thread coherence problems
*/
//=============================================================================
-void Session_ServerThread::run()
+void Session_ServerThread::Init()
{
- MESSAGE("Session_ServerThread::run "<< _argv[0]);
-
- _GUIMutex->lock(); // lock released by calling thread when ready: wait(mutex)
- MESSAGE("Server thread " << _argv[0] << " free to go...");
- _GUIMutex->unlock();
+ MESSAGE("Session_ServerThread::Init "<< _argv[0]);
for (int i=0; i<_argc; i++) SCRUTE(_argv[i]);
for (int i=0; i<NB_SRV_TYP; i++)
MESSAGE("---");
_NS->Register(myCata ,"/Kernel/ModulCatalog");
MESSAGE("---");
- _ServerLaunch->wakeAll();
- _orb->run(); // this thread wait, during process events
}
catch(CORBA::SystemException&)
{
= _root_poa->activate_object(myStudyManager_i);
myStudyManager_i->register_name("/myStudyManager");
-
- _ServerLaunch->wakeAll();
- _orb->run(); // this thread wait, during process events
}
catch(CORBA::SystemException&)
{
string absoluteName = string("/") + registryName;
_NS->Register( varComponents , absoluteName.c_str() );
MESSAGE("On attend les requetes des clients");
- try
- {
- _ServerLaunch->wakeAll();
- _orb->run();
- }
- catch( const CORBA::Exception &ex )
- {
- INFOS("Erreur systeme");
- ASSERT(0);
- }
}
catch( const SALOME_Exception &ex )
{
Engines_Container_i * myContainer
= new Engines_Container_i(_orb, factory_poa, containerName , argc , argv );
- MESSAGE("---");
- _ServerLaunch->wakeAll();
- _orb->run(); // this thread wait, during process events
}
catch(CORBA::SystemException&)
{
CORBA::String_var sior(_orb->object_to_string(obj));
mySALOME_Session->NSregister();
-
- mySALOME_Session->_remove_ref();
-
- _ServerLaunch->wakeAll();
- MESSAGE("---");
- _orb->run() ; // this thread wait, during process events
- }
+ }
catch (CORBA::SystemException&)
{
INFOS("Caught CORBA::SystemException.");
#ifndef _SESSION_SERVERTHREAD_HXX_
#define _SESSION_SERVERTHREAD_HXX_
-#include <qthread.h>
#include <CORBA.h>
+#include <string>
#include "SALOME_NamingService.hxx"
-
-#include <qwaitcondition.h>
-#include <string>
+#include <qthread.h>
using namespace std;
void WaitForServerReadiness(string serverName);
-class Session_ServerThread: public QThread
+class Session_ServerThread
{
public:
static const int NB_SRV_TYP;
char ** argv,
CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa,
- QMutex *GUIMutex,
- QWaitCondition *ServerLaunch);
+ QMutex *GUIMutex);
virtual ~Session_ServerThread();
- void run();
+ void Init();
protected:
void ActivateModuleCatalog(int argc,
char ** argv);
CORBA::ORB_var _orb;
PortableServer::POA_var _root_poa;
QMutex* _GUIMutex;
- QWaitCondition *_ServerLaunch;
SALOME_NamingService *_NS;
};