]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
PR: Server colocalisation : prototype 2
authorprascle <prascle>
Fri, 2 Apr 2004 09:06:01 +0000 (09:06 +0000)
committerprascle <prascle>
Fri, 2 Apr 2004 09:06:01 +0000 (09:06 +0000)
src/Session/Session_ServerLauncher.cxx
src/Session/Session_ServerThread.cxx

index 54e5ee8a69eed74d9997c279798d8c74b7b6ad7c..54d852aa65f492b39617142e4e4cc4a43e63ec2b 100644 (file)
@@ -171,6 +171,8 @@ void Session_ServerLauncher::CheckArgs()
 
 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++)
     {
@@ -189,11 +191,12 @@ void Session_ServerLauncher::ActivateAll()
        = new Session_ServerThread(argc, argv, _orb,_root_poa,_GUIMutex,&_ServerLaunch);
       _serverThreads.push_back(aServerThread);
 
-      //_GUIMutex->lock();             // to block server threads until wait(mutex)
       aServerThread->start();
       MESSAGE("waiting wakeAll()");
-      _ServerLaunch.wait(); // to be reseased by serverThread when ready
-      //_ServerLaunch.wait(_GUIMutex); // to be reseased by serverThread when ready
+      _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
     }
 
   // Always launch Session Server
@@ -205,8 +208,12 @@ void Session_ServerLauncher::ActivateAll()
     = new Session_ServerThread(argc, argv, _orb,_root_poa,_GUIMutex,&_ServerLaunch);
   _serverThreads.push_back(aServerThread);
 
-  //_GUIMutex->lock();             // to block server threads until wait(mutex)
   aServerThread->start();
-  _ServerLaunch.wait(); // to be reseased by serverThread when ready
+  _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
 }
 
index f7a6900ca46655487b93ad029e9e00068d78a682..6783d4a29b5a78293fd309d10582c6729926eb81 100644 (file)
@@ -172,9 +172,9 @@ void Session_ServerThread::run()
 {
   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();
+   _GUIMutex->lock(); // lock released by calling thread when ready: wait(mutex)
+   MESSAGE("Server thread " << _argv[0] << " free to go...");
+   _GUIMutex->unlock();
 
   for (int i=0; i<_argc; i++) SCRUTE(_argv[i]);
   for (int i=0; i<NB_SRV_TYP; i++)