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


Ignore:
Timestamp:
May 29, 2006, 7:27:35 PM (19 years ago)
Author:
ansari
Message:

Ajout gestionnaire signal ds ZThread et correction/adaptation gestion des threads (killthr) dans Commander - Reza 29 mai 2006

File:
1 edited

Legend:

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

    r2943 r2955  
    88#include "machdefs.h"
    99#include <pthread.h>
     10#include <signal.h>
    1011#include "pexceptions.h"
    1112
     
    3637  virtual void  run();
    3738
     39  //! Returns true if the thread has been created / started
     40  bool IfStarted() { return ((_status > 0) ? true : false); }
     41  //! Returns true if the thread is running
     42  bool IfRunning() { return ((_status == 1) ? true : false); }
     43  //! Returns true if the thread has ended normally
     44  bool IfEnded() { return ((_status == 2) ? true : false); }
     45  //! Returns true if the thread has been stopped (killed/canceled)
     46  bool IfStopped() { return ((_status == 3) ? true : false); }
     47
    3848  //! Sets the return code for the thread object
    3949  inline void   setRC(int rc) { _rc = rc; }
     
    4151  inline int    getRC() { return(_rc);
    4252 }
     53  //! Defines the function which is executed by the default run() method
    4354  inline void   setAction(ZThreadAction act, void * usp=NULL)
    4455       {  _act = act;  _usp = usp; }
    4556
     57  //! Call this method to activate the stop/exit handler on signal \b sig
     58  static void ActivateExitOnSignal(int sig=SIGUSR1);
    4659
     60  /*!
     61    \brief Set/changes the current thread cancelability state
     62    see pthread_setcancelstate()
     63    \b st = PTHREAD_CANCEL_ENABLE  or PTHREAD_CANCEL_DISABLE
     64  */
    4765  static inline void setCancelState(int st= PTHREAD_CANCEL_ENABLE)
    4866       { int ocs; pthread_setcancelstate(st, &ocs); }
    4967  // PTHREAD_CANCEL_ENABLE  ou PTHREAD_CANCEL_DISABLE
     68
     69  /*!
     70    \brief Set/changes the current thread cancelability state
     71    see pthread_setcanceltype()
     72    \b ct = PTHREAD_CANCEL_DEFERRED or PTHREAD_CANCEL_ASYNCHRONOUS
     73  */
    5074  static inline void setCancelType(int ct= PTHREAD_CANCEL_DEFERRED)
    5175       { int oct; pthread_setcanceltype(ct, &oct); }
    5276  // PTHREAD_CANCEL_DEFERRED  ou  PTHREAD_CANCEL_ASYNCHRONOUS
    5377
     78  virtual void  run_p();
    5479
    5580  // ---- Attribute variables ----
     
    5782  size_t _ssize;
    5883  int _rc;
    59   bool _initok;
     84  int _status; // 0 : not started, 1: running, 2: ended, 3:stopped
    6085
    6186  ZThreadAction _act;
Note: See TracChangeset for help on using the changeset viewer.