Changeset 2490 in Sophya for trunk/SophyaPI/PIext


Ignore:
Timestamp:
Jan 2, 2004, 12:31:36 AM (22 years ago)
Author:
ansari
Message:

Suite modifs pour piapp multi-thread - introduction de lock lors de la mise a jour de la fenetre ObjMgr par NamedObjMgr - Reza 1 Jan 2004

Location:
trunk/SophyaPI/PIext
Files:
6 edited

Legend:

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

    r2460 r2490  
    108108
    109109/* --Methode-- */
    110 NamedObjMgr::NamedObjMgr()
    111 {
     110NamedObjMgr::NamedObjMgr(bool fgimgapp)
     111{
     112_fgimgapp = fgimgapp;
    112113if (fgOInit == 0) {
    113114  myNObj = 0;
     
    302303if (myImgApp)  {
    303304  string str = '/' + dirname;
     305  if ( !_fgimgapp )  ZSync(myImgApp->getMutex(),2);
    304306  (myImgApp->ObjMgrW())->AddDirectory(str.c_str(), myDirId);
    305307  }
     
    333335  }
    334336
    335 if (myImgApp) 
     337if (myImgApp) {
     338  if ( !_fgimgapp )  ZSync(myImgApp->getMutex(),2);
    336339  (myImgApp->ObjMgrW())->DelDirectory((*it).second.id);
     340}
    337341myDirs->erase(it);
    338342if (verbeux) cout << "NamedObjMgr::DeleteDir() " << dirname << " deleted " << endl; 
     
    459463list<string>::iterator ii;
    460464for(ii=odel.begin(); ii != odel.end(); ii++)  DelObj(*ii,true);
    461 if (myImgApp) 
     465if (myImgApp) {
     466  if ( !_fgimgapp )  ZSync(myImgApp->getMutex(),2);
    462467  (myImgApp->ObjMgrW())->UpdateList(did);
     468}
    463469}
    464470
     
    561567(*itr).second.nobj++;
    562568
    563 if ( (myImgApp != NULL) && (myImgApp->ObjMgrW())->Visible() ) {
    564   string oln = nobj + "  (T= " + no.obja->GetDataObjType() + ")" ;
    565   (myImgApp->ObjMgrW())->AddObjList(did, oln.c_str(), no.oid);
    566   }
     569if (myImgApp != NULL) {
     570  if ( !_fgimgapp )  ZSync(myImgApp->getMutex(),2);
     571  if ( (myImgApp->ObjMgrW())->Visible() ) {
     572    string oln = nobj + "  (T= " + no.obja->GetDataObjType() + ")" ;
     573    (myImgApp->ObjMgrW())->AddObjList(did, oln.c_str(), no.oid);
     574  }
     575}
    567576if (verbeux) cout << "NamedObjMgr::AddObj()  Object " << nom << " ( " 
    568577     << typeid(*obj).name() << " ) added (Total= " << myObjs->size() << ")" << endl; 
     
    632641(*itr).second.nobj++;
    633642
    634 if ( (myImgApp != NULL) && (myImgApp->ObjMgrW())->Visible() ) {
    635   (myImgApp->ObjMgrW())->DelObjList(dids, no.oid);
    636   string oln = n2 + "  (T= " + no.obja->GetDataObjType() + ")" ;
    637   (myImgApp->ObjMgrW())->AddObjList(did, oln.c_str(), no.oid);
     643if (myImgApp != NULL) {
     644  if ( !_fgimgapp )  ZSync(myImgApp->getMutex(),2);
     645  if ( (myImgApp->ObjMgrW())->Visible() ) {
     646    (myImgApp->ObjMgrW())->DelObjList(dids, no.oid);
     647    string oln = n2 + "  (T= " + no.obja->GetDataObjType() + ")" ;
     648    (myImgApp->ObjMgrW())->AddObjList(did, oln.c_str(), no.oid);
     649  }
    638650}
    639651if (verbeux)
     
    681693if (fgd) delete (*it).second.obj;
    682694
    683 if ( (myImgApp != NULL) && (myImgApp->ObjMgrW())->Visible() ) {
    684   int olid = (*it).second.oid;
    685   (myImgApp->ObjMgrW())->DelObjList(did, olid);
     695if (myImgApp != NULL) {
     696  if ( !_fgimgapp )  ZSync(myImgApp->getMutex(),2);
     697  if ( (myImgApp->ObjMgrW())->Visible() ) {
     698    int olid = (*it).second.oid;
     699    (myImgApp->ObjMgrW())->DelObjList(did, olid);
     700  }
    686701}
    687702myObjs->erase(it);
     
    14741489{
    14751490if (!myImgApp)  return;
     1491if ( !_fgimgapp )  ZSync(myImgApp->getMutex(),2);
     1492
    14761493(myImgApp->ObjMgrW())->ClearObjList();
    14771494
  • trunk/SophyaPI/PIext/nobjmgr.h

    r2322 r2490  
    2626public:
    2727// Constructeur et destructeur
    28                         NamedObjMgr();
     28                        NamedObjMgr(bool fgimgapp=false);
    2929  virtual               ~NamedObjMgr();
    3030
     
    107107  static bool CheckDirName(string & nom);
    108108  static int  ParseObjectName(string & nom, string & nomrep, string & nomobj);
     109
     110protected:
     111  bool _fgimgapp;  // true -> cree par PIStdImgApp / pour gestion de thread
    109112};
    110113
  • trunk/SophyaPI/PIext/piacmd.cc

    r2489 r2490  
    146146// static PIACmd* curpiacmd = NULL;
    147147/* --Methode-- */
    148 PIACmd::PIACmd(NamedObjMgr* omg, PIStdImgApp* app)
     148PIACmd::PIACmd(PIStdImgApp* app)
    149149  : Commander()
    150150{
    151 mObjMgr = omg;
     151mObjMgr = new NamedObjMgr;
    152152mImgApp = app;
    153153helpwin = new PIAHelpWind(app, this);
     
    165165RegisterCommand(kw, usage, NULL, grp);
    166166
    167 basexec = new PIABaseExecutor(this, omg, app);
     167basexec = new PIABaseExecutor(this, mObjMgr, app);
    168168fitexec = new PIAFitter(this, app);
    169169pawexec = new PAWExecutor(this, app);
     
    188188PIACmd::~PIACmd()
    189189{
    190  
     190delete mObjMgr;
    191191delete helpwin;
    192192delete cxxexwin;
  • trunk/SophyaPI/PIext/piacmd.h

    r2486 r2490  
    3535  //  static PIACmd*    GetInterpreter();
    3636
    37                         PIACmd(NamedObjMgr* omg, PIStdImgApp* app);
     37                        PIACmd(PIStdImgApp* app);
    3838  virtual               ~PIACmd();
    3939
  • trunk/SophyaPI/PIext/pistdimgapp.cc

    r2489 r2490  
    251251// RedirectStdOutErr(true);  pas par defaut
    252252 
    253 mObjMgr = new NamedObjMgr;
    254 mCmd = new PIACmd(mObjMgr, this);
     253mObjMgr = new NamedObjMgr(true);
     254mCmd = new PIACmd(this);
    255255
    256256// Pas trop de message de la part de NamedObjMgr
     
    322322
    323323SetReady();
     324fg_glsynlock = false;
    324325}
    325326
     
    418419}
    419420
    420 bool fg_gls_lock = false;
     421
    421422while (mStop) {
    422423  thr_glsyn.lock(); //  <ZThread>
     424  fg_glsynlock = true;
    423425  while (XtAppPending(*appctx) != 0) {
    424426    XtAppNextEvent(*appctx, &evt);
    425427    XtDispatchEvent(&evt);
    426428  }
     429  fg_glsynlock = false;
    427430  thr_glsyn.unlock(); //  <ZThread>
    428431  //  thr_glsyn.wait();
  • trunk/SophyaPI/PIext/pistdimgapp.h

    r2486 r2490  
    5858     virtual void   Run();
    5959     inline ZMutex &   getMutex() { return thr_glsyn; }
     60     inline bool       isGlSyncLocked() { return fg_glsynlock; }
    6061
    6162  // Methodes d'Affichage generique
     
    234235  // Attributs pour controle de thread
    235236    ZMutex thr_glsyn;
     237    bool fg_glsynlock;  // true: thr_glsyn locke pour traitement evts
    236238};
    237239
Note: See TracChangeset for help on using the changeset viewer.