Changeset 3718 in Sophya for trunk/SophyaLib/SysTools/zthread.h


Ignore:
Timestamp:
Dec 28, 2009, 10:05:51 PM (16 years ago)
Author:
ansari
Message:

1/ Corrections et modifications mineures ds ZThread, et ajout des classes

ParallelTaskInterface, ParalExThread, ParallelExecutor pour l'execution

de fonctions en parallele dans des threads, Reza 28/12/2009

File:
1 edited

Legend:

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

    r3586 r3718  
    3131  explicit      ZThread(size_t stacksize=0);
    3232  virtual       ~ZThread();
     33  //! Change the thread stack-size, specified in bytes. Can only be called before the thread is started
     34  inline void   setStackSize(size_t ssz) { _ssize=ssz; }
     35  //! Change the thread stack-size, specified in kilobytes. Can only be called before the thread is started
     36  inline void   setStackSizekb(size_t sszk) { _ssize=sszk*1024; }
     37
    3338  void          start();
    3439  void          cancel();
    3540  void          kill(int sig);
     41  void          join();
    3642
    37   void          join();
    3843  virtual void  run();
    3944
    4045  //! Returns true if the thread has been created / started
    41   bool IfStarted() { return ((_status > 0) ? true : false); }
     46  bool IfStarted() { return (((_fgstarted)||(_status>0)) ? true : false); }
    4247  //! Returns true if the thread is running
    43   bool IfRunning() { return ((_status == 1) ? true : false); }
     48  bool IfRunning() { return ((_status == 2) ? true : false); }
    4449  //! Returns true if the thread has ended normally
    45   bool IfEnded() { return ((_status == 2) ? true : false); }
     50  bool IfEnded() { return ((_status == 3) ? true : false); }
    4651  //! Returns true if the thread has been stopped (killed/canceled)
    47   bool IfStopped() { return ((_status == 3) ? true : false); }
     52  bool IfStopped() { return ((_status == 5) ? true : false); }
    4853
    4954  //! Sets the return code for the thread object
     
    7782  // PTHREAD_CANCEL_DEFERRED  ou  PTHREAD_CANCEL_ASYNCHRONOUS
    7883
     84  /*!
     85    \brief This method is only for internal use by zthread.cc and should not be called by users
     86  */
    7987  virtual void  run_p();
    8088
     
    8391  size_t _ssize;
    8492  int _rc;
    85   int _status; // 0 : not started, 1: running, 2: ended, 3:stopped
    86 
     93  int _status; // 0 : not started, 1 : started, 2: running, 3: ended, 5:stopped
     94  bool _fgstarted;   // false -> true par appel a start()
    8795  ZThreadAction _act;
    8896  void * _usp;
Note: See TracChangeset for help on using the changeset viewer.