Changeset 2492 in Sophya for trunk/SophyaPI/PIext
- Timestamp:
- Jan 6, 2004, 6:05:25 PM (22 years ago)
- Location:
- trunk/SophyaPI/PIext
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PIext/nobjmgr.cc
r2491 r2492 321 321 if (myImgApp) { 322 322 string str = '/' + dirname; 323 if ( !_fgimgapp ) ZSync(myImgApp->getMutex(),2);323 if ( !_fgimgapp ) myImgApp->LockMutex(); 324 324 (myImgApp->ObjMgrW())->AddDirectory(str.c_str(), myDirId); 325 } 325 if ( !_fgimgapp ) myImgApp->UnlockMutex(true); 326 } 326 327 if (verbeux) cout << "NamedObjMgr::CreateDir() " << dirname << " Created " << endl; 327 328 return(true); … … 355 356 356 357 if (myImgApp) { 357 if ( !_fgimgapp ) ZSync(myImgApp->getMutex(),2);358 if ( !_fgimgapp ) myImgApp->LockMutex(); 358 359 (myImgApp->ObjMgrW())->DelDirectory((*it).second.id); 360 if ( !_fgimgapp ) myImgApp->UnlockMutex(true); 359 361 } 360 362 myDirs->erase(it); … … 497 499 for(ii=odel.begin(); ii != odel.end(); ii++) DelObj(*ii,true); 498 500 if (myImgApp) { 499 if ( !_fgimgapp ) ZSync(myImgApp->getMutex(),2);501 if ( !_fgimgapp ) myImgApp->LockMutex(); 500 502 (myImgApp->ObjMgrW())->UpdateList(did); 503 if ( !_fgimgapp ) myImgApp->UnlockMutex(true); 501 504 } 502 505 } … … 607 610 608 611 if (myImgApp != NULL) { 609 if ( !_fgimgapp ) ZSync(myImgApp->getMutex(),2);612 if ( !_fgimgapp ) myImgApp->LockMutex(); 610 613 if ( (myImgApp->ObjMgrW())->Visible() ) { 611 614 string oln = nobj + " (T= " + no.obja->GetDataObjType() + ")" ; 612 615 (myImgApp->ObjMgrW())->AddObjList(did, oln.c_str(), no.oid); 613 616 } 617 if ( !_fgimgapp ) myImgApp->UnlockMutex(true); 614 618 } 615 619 if (verbeux) cout << "NamedObjMgr::AddObj() Object " << nom << " ( " … … 689 693 690 694 if (myImgApp != NULL) { 691 if ( !_fgimgapp ) ZSync(myImgApp->getMutex(),2);695 if ( !_fgimgapp ) myImgApp->LockMutex(); 692 696 if ( (myImgApp->ObjMgrW())->Visible() ) { 693 697 (myImgApp->ObjMgrW())->DelObjList(dids, no.oid); … … 695 699 (myImgApp->ObjMgrW())->AddObjList(did, oln.c_str(), no.oid); 696 700 } 701 if ( !_fgimgapp ) myImgApp->UnlockMutex(true); 697 702 } 698 703 if (verbeux) … … 741 746 if (myImgApp) { 742 747 //DBG cerr << " *DBG* NamedObjMgr::DelObj Sz= " << (*it).second.wrsid.size() << endl; 748 // Si appel venant de PIStdImgApp, il ne faut pas locker le Mutex global de la boucle d'evts 749 bool fglock = (_fgimgapp) ? false : true; 750 if (fglock) myImgApp->LockMutex(); 743 751 for(ii=(*it).second.wrsid.begin(); ii != (*it).second.wrsid.end(); ii++) 744 752 myImgApp->DelWRsId((*ii)); 753 if (fglock) myImgApp->UnlockMutex(true); 745 754 } 746 755 delete (*it).second.obja; // destruction de l'adaptateur … … 748 757 749 758 if (myImgApp != NULL) { 750 if ( !_fgimgapp ) ZSync(myImgApp->getMutex(),2);759 if ( !_fgimgapp ) myImgApp->LockMutex(); 751 760 if ( (myImgApp->ObjMgrW())->Visible() ) { 752 761 int olid = (*it).second.oid; 753 762 (myImgApp->ObjMgrW())->DelObjList(did, olid); 754 763 } 764 if ( !_fgimgapp ) myImgApp->UnlockMutex(true); 755 765 } 756 766 myObjs->erase(it); … … 1593 1603 if (!myImgApp) return; 1594 1604 ZSync(*myMutex); 1595 if ( !_fgimgapp ) ZSync(myImgApp->getMutex(),2);1605 if ( !_fgimgapp ) myImgApp->LockMutex(); 1596 1606 1597 1607 (myImgApp->ObjMgrW())->ClearObjList(); … … 1606 1616 (myImgApp->ObjMgrW())->AddObj(cn.c_str(), (*it).second.oid); 1607 1617 } 1618 1619 if ( !_fgimgapp ) myImgApp->UnlockMutex(true); 1608 1620 } 1609 1621 -
trunk/SophyaPI/PIext/pistdimgapp.cc
r2491 r2492 2 2 #include <stdlib.h> 3 3 #include <stdio.h> 4 #include <unistd.h> 4 5 #include <string.h> 5 6 … … 406 407 { 407 408 while (!_fgstop) { 408 usleep( 1000);409 usleep(2000); 409 410 _app->getMutex().broadcast(); 410 411 } … … 443 444 444 445 thr_glsyn.lock(); // <ZThread> 445 //D BG int klp = 0;446 //DEL-DBG int klp = 0; 446 447 while (mStop) { 447 448 fg_glsynlock = true; … … 451 452 XtDispatchEvent(&evt); 452 453 nevtproc++; 453 if (nevtproc >= 50) break;454 if (nevtproc >= 200) break; 454 455 } 455 456 fg_glsynlock = false; 457 //DBG cout << " "DBG-Run:: Going to wait ... " << klp << endl; 456 458 thr_glsyn.wait(); // <ZThread> 457 // 459 //DBG cout << "DBG-Run:: Out of wait " << ++klp << endl; 458 460 // usleep(1000); 459 461 } … … 626 628 } 627 629 630 class SyncPIS { 631 public: 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 647 private: 648 ZMutex * _mtx; 649 int _sigbr; 650 bool _fglock; 651 inline SyncPIS() {_mtx = NULL; _sigbr = 0; _fglock = false; } 652 }; 653 628 654 629 655 /* --Methode-- */ … … 656 682 657 683 // <ZThread> global PIApplication event loop synchronisation 658 if (fglock) ZSync zs(thr_glsyn, 2); 684 SyncPIS zs(getMutex(), fglock, 2); 659 685 660 686 // Choix de la taille de fenetre … … 726 752 727 753 // <ZThread> global PIApplication event loop synchronisation 728 if (fglock) ZSync zs(thr_glsyn, 2); 754 SyncPIS zs(getMutex(), fglock, 2); 729 755 730 756 // Trace en superpoistion … … 830 856 831 857 // <ZThread> global PIApplication event loop synchronisation 832 if (fglock) ZSync zs(thr_glsyn, 2); 858 SyncPIS zs(getMutex(), fglock, 2); 833 859 834 860 // Trace en superpoistion -
trunk/SophyaPI/PIext/pistdimgapp.h
r2491 r2492 58 58 virtual void Run(); 59 59 inline ZMutex & getMutex() { return thr_glsyn; } 60 inline void LockMutex() { thr_glsyn.lock(); } 61 inline void UnlockMutex(bool fgbr=false) 62 { thr_glsyn.broadcast(); thr_glsyn.unlock(); } 60 63 inline bool isGlSyncLocked() { return fg_glsynlock; } 61 64
Note:
See TracChangeset
for help on using the changeset viewer.