Changeset 2492 in Sophya for trunk/SophyaPI/PIext/pistdimgapp.cc


Ignore:
Timestamp:
Jan 6, 2004, 6:05:25 PM (22 years ago)
Author:
ansari
Message:

Suite debug piapp multithread : on ne peut pas utiliser ZSync() ds un if (destructeur appele de suite) - Reza 06/01/2004

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PIext/pistdimgapp.cc

    r2491 r2492  
    22#include <stdlib.h>
    33#include <stdio.h>
     4#include <unistd.h>
    45#include <string.h>
    56
     
    406407  {
    407408    while (!_fgstop) {
    408       usleep(1000);
     409      usleep(2000);
    409410      _app->getMutex().broadcast();
    410411    }
     
    443444
    444445thr_glsyn.lock(); //  <ZThread>
    445 //DBG int klp = 0;
     446//DEL-DBG int klp = 0;
    446447while (mStop) {
    447448  fg_glsynlock = true;
     
    451452    XtDispatchEvent(&evt);
    452453    nevtproc++;
    453     if (nevtproc >= 50)  break;
     454    if (nevtproc >= 200)  break;
    454455  }
    455456  fg_glsynlock = false;
     457  //DBG cout << " "DBG-Run:: Going to wait ... " << klp << endl;
    456458  thr_glsyn.wait();  //  <ZThread>
    457   //  cout << "DBG-Run:: Out of wait " << ++klp << endl; 
     459  //DBG cout << "DBG-Run:: Out of wait " << ++klp << endl; 
    458460    //  usleep(1000);
    459461}
     
    626628}
    627629
     630class SyncPIS {
     631public:
     632  explicit SyncPIS(ZMutex & mtx, bool fglock=true, int sigbr=0)
     633  {
     634  _mtx = &mtx; _sigbr = sigbr;
     635  _fglock = fglock;
     636  if (_fglock)  mtx.lock();
     637  }
     638  ~SyncPIS()
     639  {
     640    if (_fglock && (_mtx != NULL) ) {
     641      if (_sigbr == 1) _mtx->signal();
     642      else  if (_sigbr == 2) _mtx->broadcast();
     643      _mtx->unlock();
     644    }
     645  }
     646
     647private:
     648  ZMutex * _mtx;
     649  int _sigbr;
     650  bool _fglock;
     651  inline        SyncPIS() {_mtx = NULL; _sigbr = 0; _fglock = false; }
     652};
     653
    628654
    629655/* --Methode-- */
     
    656682
    657683// <ZThread> global PIApplication event loop synchronisation
    658 if (fglock) ZSync zs(thr_glsyn, 2); 
     684SyncPIS zs(getMutex(), fglock, 2);
    659685
    660686// Choix de la taille de fenetre
     
    726752
    727753// <ZThread> global PIApplication event loop synchronisation
    728 if (fglock) ZSync zs(thr_glsyn, 2); 
     754SyncPIS zs(getMutex(), fglock, 2);
    729755
    730756// Trace en superpoistion
     
    830856
    831857// <ZThread> global PIApplication event loop synchronisation
    832 if (fglock) ZSync zs(thr_glsyn, 2); 
     858SyncPIS zs(getMutex(), fglock, 2);
    833859
    834860// Trace en superpoistion
Note: See TracChangeset for help on using the changeset viewer.