Changeset 2488 in Sophya


Ignore:
Timestamp:
Dec 29, 2003, 1:34:11 AM (22 years ago)
Author:
ansari
Message:

Ajout possibilite d'appel a pthread_signal/broadcast ds le destructeur de ZSync() - Reza 29/12/2003

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/SysTools/zthread.h

    r2212 r2488  
    9393class ZSync {
    9494public:
    95   explicit inline  ZSync(ZMutex & mtx) {_mtx = &mtx; mtx.lock(); }
    96   inline           ~ZSync() { if (_mtx) _mtx->unlock(); }
     95  explicit inline  ZSync(ZMutex & mtx, int sigbr=0)
     96  {_mtx = &mtx; _sigbr = sigbr; mtx.lock(); }
     97  inline           ~ZSync()
     98  {
     99    if (_mtx) {
     100      _mtx->unlock();
     101      if (_sigbr == 1) _mtx->signal();
     102      else  if (_sigbr == 2) _mtx->broadcast();
     103    }
     104  }
    97105
    98106private:
    99107  ZMutex * _mtx;
    100   inline        ZSync() {_mtx = NULL; }
     108  int _sigbr;
     109  inline        ZSync() {_mtx = NULL; _sigbr = 0; }
    101110
    102111};
Note: See TracChangeset for help on using the changeset viewer.