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


Ignore:
Timestamp:
Jan 4, 2004, 8:02:44 PM (22 years ago)
Author:
ansari
Message:

Suite des modifs pour piapp multi-threads
1) Ajout Mutex de synchronisation ds ls classe NamedObjMgr
2) Suite controle de gestion d'appel aux methodes de PIStdImgApp depuis
la classe elle-meme, a travers le NamedObjMgr
3) Modification de la boucle d'evenements, avec un thread de reveil
periodique

Reza, 4 Janvier 2004

File:
1 edited

Legend:

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

    r2490 r2491  
    383383
    384384
     385/*
    385386class RunAlarm : public Periodic {
    386387public:
     
    393394  PIStdImgApp* _app;
    394395};
    395 
     396*/
     397
     398class Reveil : public ZThread {
     399public:
     400  Reveil(PIStdImgApp* app) :
     401    ZThread()
     402  { _app = app; _fgstop = false; }
     403  virtual ~Reveil() { }
     404  inline void Stop() { _fgstop = true; }
     405  virtual void run()
     406  {
     407    while (!_fgstop) {
     408      usleep(1000);
     409      _app->getMutex().broadcast();
     410    }
     411  }
     412
     413  PIStdImgApp* _app;
     414  bool _fgstop;
     415};
    396416/* --Methode-- */
    397417void PIStdImgApp::Run()
     
    409429// Creation et demarrage de l'objet de reveil periodique
    410430// de la boucle d'evts
    411 RunAlarm * mru = new RunAlarm(this);
    412 //mru->Start();
     431/* RunAlarm * mru = new RunAlarm(this);
     432   mru->Start(); */
     433Reveil* mrv = new Reveil(this);
     434mrv->start();
    413435// Demarrage du thread de l'interpreteur
    414436CmdInterpreter()->start();
     
    420442
    421443
     444thr_glsyn.lock(); //  <ZThread>
     445//DBG int klp = 0;
    422446while (mStop) {
    423   thr_glsyn.lock(); //  <ZThread>
    424447  fg_glsynlock = true;
     448  int nevtproc = 0;
    425449  while (XtAppPending(*appctx) != 0) {
    426450    XtAppNextEvent(*appctx, &evt);
    427451    XtDispatchEvent(&evt);
     452    nevtproc++;
     453    if (nevtproc >= 50)  break;
    428454  }
    429455  fg_glsynlock = false;
    430   thr_glsyn.unlock(); //  <ZThread>
    431   //  thr_glsyn.wait();
    432   usleep(1000);
    433 }
    434 
    435 delete mru;
     456  thr_glsyn.wait();  //  <ZThread>
     457  //  cout << "DBG-Run:: Out of wait " << ++klp << endl; 
     458    //  usleep(1000);
     459}
     460
     461thr_glsyn.unlock();  //  <ZThread>
     462mrv->Stop();
     463delete mrv;
     464// delete mru;
    436465return;
    437466}
     
    599628
    600629/* --Methode-- */
    601 int PIStdImgApp::DispImage(P2DArrayAdapter* nouv, string const & name, string const& sop, int oid)
     630int PIStdImgApp::DispImage(P2DArrayAdapter* nouv, string const & name, string const& sop,
     631                           int oid, bool fglock)
    602632{
    603633PIImage* pii;
     
    626656
    627657// <ZThread> global PIApplication event loop synchronisation
    628 ZSync zs(thr_glsyn, 2); 
     658if (fglock) ZSync zs(thr_glsyn, 2); 
    629659
    630660// Choix de la taille de fenetre
     
    682712/* --Methode-- */
    683713int PIStdImgApp::DispScDrawer(PIDrawer* scd, string const & name, string const& sop,
    684                               string title, int oid)
     714                              string title, int oid, bool fglock)
    685715{
    686716if (scd == NULL)
     
    696726
    697727// <ZThread> global PIApplication event loop synchronisation
    698 ZSync zs(thr_glsyn, 2); 
     728if (fglock) ZSync zs(thr_glsyn, 2); 
    699729
    700730// Trace en superpoistion
     
    785815/* --Methode-- */
    786816int PIStdImgApp::Disp3DDrawer(PIDrawer3D* dr3, string const & name, string const& sop,
    787                               string title, int oid)
     817                              string title, int oid, bool fglock)
    788818{
    789819if (dr3 == NULL)
     
    800830
    801831// <ZThread> global PIApplication event loop synchronisation
    802 ZSync zs(thr_glsyn, 2); 
     832if (fglock) ZSync zs(thr_glsyn, 2); 
    803833
    804834// Trace en superpoistion
Note: See TracChangeset for help on using the changeset viewer.