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++)
{
= 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
= 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
}
{
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++)