Changeset 2489 in Sophya


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

Tentatives pour regler les conflits/plantage ds spiapp multi-thread/pb en particulier avec PIACmd::ShowMessage() appele lorsque traceon - Reza 29/12/2003

Location:
trunk/SophyaPI/PIext
Files:
3 edited

Legend:

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

    r2486 r2489  
    344344{
    345345  Commander::SetCurrentPrompt(pr);
    346   if (mImgApp) mImgApp->GetConsole()->SetPrompt(pr);
     346  if (mImgApp) {
     347    ZSync(mImgApp->getMutex());
     348    mImgApp->GetConsole()->SetPrompt(pr);
     349  }
    347350}
    348351
     
    350353void PIACmd::ShowMessage(const char * msg, int att)
    351354{
     355  /*
     356  Il faut faire quelque chose pour gerer correctement ca en multithread
    352357  char va = (att == 0) ? 0 : PIVA_Magenta;
    353   if (mImgApp) mImgApp->GetConsole()->AddStr(msg, va);
    354 }
     358  if (mImgApp) {
     359    ZSync(mImgApp->getMutex());
     360    mImgApp->GetConsole()->AddStr(msg, va);
     361  }
     362  */
     363Commander::ShowMessage(msg, att);
     364}
  • trunk/SophyaPI/PIext/piaversion.h

    r2373 r2489  
    22#define PIAPPVERSION_H_SEEN
    33
    4 #define PIAPP_VERSIONNUMBER  3.95
     4#define PIAPP_VERSIONNUMBER  3.96
    55
    66#endif
  • trunk/SophyaPI/PIext/pistdimgapp.cc

    r2486 r2489  
    7676{
    7777  if (_app) {
    78     _app->ExecuteExtCommand();
     78    // RZDEL: Normalement, il ne devrait plus y avoir besoin de cette
     79    // methode avec le thread separe de l'interpreteur - Reza 27/12/2003
     80    //    _app->ExecuteExtCommand();
    7981    _app->UpdateStatResourceInfo();
    8082  }
     
    380382
    381383
     384class RunAlarm : public Periodic {
     385public:
     386  RunAlarm(PIStdImgApp* app) :
     387    Periodic(1)
     388  { _app = app; SetIntervalms(1); }
     389  ~RunAlarm() { }
     390  virtual void DoPeriodic()
     391  { _app->getMutex().broadcast(); }
     392  PIStdImgApp* _app;
     393};
     394
    382395/* --Methode-- */
    383396void PIStdImgApp::Run()
     
    393406else mStop = true;   // On rerentre apres un stop
    394407
    395 mCmd->start();
    396 
     408// Creation et demarrage de l'objet de reveil periodique
     409// de la boucle d'evts
     410RunAlarm * mru = new RunAlarm(this);
     411//mru->Start();
     412// Demarrage du thread de l'interpreteur
     413CmdInterpreter()->start();
     414
     415// Soumission de la commande exterieur a executer
     416if (fg_exc_cmd) {
     417  fg_exc_cmd = false;
     418}
     419
     420bool fg_gls_lock = false;
    397421while (mStop) {
    398422  thr_glsyn.lock(); //  <ZThread>
    399   if (XtAppPending(*appctx) != 0) {
     423  while (XtAppPending(*appctx) != 0) {
    400424    XtAppNextEvent(*appctx, &evt);
    401425    XtDispatchEvent(&evt);
    402426  }
    403   thr_glsyn.unlock(); // <ZThread>
     427  thr_glsyn.unlock(); //  <ZThread>
     428  //  thr_glsyn.wait();
    404429  usleep(1000);
    405430}
     431
     432delete mru;
    406433return;
    407434}
     
    514541  try {
    515542    //    mCmd->Interpret(s);
    516     mCmd->AddInputLine(s);
     543    CmdInterpreter()->AddInputLine(s);
    517544    } 
    518545  catch ( PThrowable & exc ) {
     
    596623
    597624// <ZThread> global PIApplication event loop synchronisation
    598 ZSync zs(thr_glsyn); 
     625ZSync zs(thr_glsyn, 2); 
    599626
    600627// Choix de la taille de fenetre
     
    666693
    667694// <ZThread> global PIApplication event loop synchronisation
    668 ZSync zs(thr_glsyn); 
     695ZSync zs(thr_glsyn, 2); 
    669696
    670697// Trace en superpoistion
     
    770797
    771798// <ZThread> global PIApplication event loop synchronisation
    772 ZSync zs(thr_glsyn); 
     799ZSync zs(thr_glsyn, 2); 
    773800
    774801// Trace en superpoistion
     
    856883}
    857884
     885// RZDEL: Normalement, il ne devrait plus y avoir besoin de cette
     886// methode avec le thread separe de l'interpreteur - Reza 27/12/2003
    858887/* --Methode-- */
    859888int PIStdImgApp::ExecuteExtCommand()
     
    869898void PIStdImgApp::AddText(string const & txt, double xp, double yp, string const& sop, bool fgcn)
    870899{
     900// <ZThread> global PIApplication event loop synchronisation
     901ZSync zs(thr_glsyn, 2); 
     902
    871903PIDrawer *eld=CurrentElDrawer();
    872904if (eld == NULL) return;
     
    893925                              string const& optss, bool fgcn)
    894926{
     927// <ZThread> global PIApplication event loop synchronisation
     928ZSync zs(thr_glsyn, 2); 
     929
    895930PIDrawer *eld=CurrentElDrawer();
    896931if (eld == NULL) return;
     
    918953                          string const& sop, bool fgarrow, bool fgcn)
    919954{
     955// <ZThread> global PIApplication event loop synchronisation
     956ZSync zs(thr_glsyn, 2); 
     957
    920958PIDrawer *eld=CurrentElDrawer();
    921959if (eld == NULL) return;
     
    941979                               string const& sop, bool fgfill, bool fgcn)
    942980{
     981// <ZThread> global PIApplication event loop synchronisation
     982ZSync zs(thr_glsyn, 2); 
     983
    943984PIDrawer *eld=CurrentElDrawer();
    944985if (eld == NULL) return;
     
    9781019                            bool fgfill, bool fgcn)
    9791020{
     1021// <ZThread> global PIApplication event loop synchronisation
     1022ZSync zs(thr_glsyn, 2); 
     1023
    9801024PIDrawer *eld=CurrentElDrawer();
    9811025if (eld == NULL) return;
     
    10021046                         string const& sop, bool fgfill, bool fgcn)
    10031047{
     1048// <ZThread> global PIApplication event loop synchronisation
     1049ZSync zs(thr_glsyn, 2); 
     1050
    10041051PIDrawer *eld=CurrentElDrawer();
    10051052if (eld == NULL) return;
     
    10231070                         double x3, double y3, string const& sop, bool fgfill, bool fgcn)
    10241071{
     1072// <ZThread> global PIApplication event loop synchronisation
     1073ZSync zs(thr_glsyn, 2); 
     1074
    10251075PIDrawer *eld=CurrentElDrawer();
    10261076if (eld == NULL) return;
     
    10461096                          string const& sop, bool fgfill, bool fgcn)
    10471097{
     1098// <ZThread> global PIApplication event loop synchronisation
     1099ZSync zs(thr_glsyn, 2); 
     1100
    10481101PIDrawer *eld=CurrentElDrawer();
    10491102if (eld == NULL) return;
     
    10701123void PIStdImgApp::SetTitle(string const & titletop, string const & titlebottom, string const& sop)
    10711124{
     1125// <ZThread> global PIApplication event loop synchronisation
     1126ZSync zs(thr_glsyn, 2); 
     1127
    10721128PIDrawer *eld=CurrentElDrawer();
    10731129if (eld == NULL) return;
     
    10931149void PIStdImgApp::SetAxeLabels(string const & xLabel, string const & yLabel, string const& sop)
    10941150{
     1151// <ZThread> global PIApplication event loop synchronisation
     1152ZSync zs(thr_glsyn, 2); 
     1153
    10951154PIDrawer *eld=CurrentElDrawer();
    10961155if (eld == NULL) return;
     
    14071466  int nlx = 0;
    14081467  bool fgx = false;
    1409   if (mCmd) fgx = mCmd->isRunning(nlx);
     1468  if ( CmdInterpreter() ) fgx = CmdInterpreter()->isRunning(nlx);
    14101469  if (!fgx) {
    14111470    lab = "PIACmdThread Idle";
     
    15471606
    15481607    case 10100 :
    1549       mCmd->ShowHelpWindow();
     1608      CmdInterpreter()->ShowHelpWindow();
    15501609      break;
    15511610
     
    16031662        cmd += nomobj;  cmd += " ";  cmd += afname;
    16041663        try {
    1605           mCmd->Interpret(cmd);
     1664          CmdInterpreter()->AddInputLine(cmd);
     1665          //      mCmd->Interpret(cmd);
    16061666        } 
    16071667        catch ( PThrowable & exc ) {
     
    17051765
    17061766  case 10304 :
    1707     mCmd->ShowCxxExecWindow();
     1767    CmdInterpreter()->ShowCxxExecWindow();
    17081768    break;
    17091769
     
    19812041    break;
    19822042  case 10606:
    1983     mCmd->ShowCxxOptionWindow();
     2043    CmdInterpreter()->ShowCxxOptionWindow();
    19842044    break;
    19852045  default:
Note: See TracChangeset for help on using the changeset viewer.