Changeset 2955 in Sophya for trunk/SophyaLib/SysTools/zthread.h
- Timestamp:
- May 29, 2006, 7:27:35 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/SysTools/zthread.h
r2943 r2955 8 8 #include "machdefs.h" 9 9 #include <pthread.h> 10 #include <signal.h> 10 11 #include "pexceptions.h" 11 12 … … 36 37 virtual void run(); 37 38 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 38 48 //! Sets the return code for the thread object 39 49 inline void setRC(int rc) { _rc = rc; } … … 41 51 inline int getRC() { return(_rc); 42 52 } 53 //! Defines the function which is executed by the default run() method 43 54 inline void setAction(ZThreadAction act, void * usp=NULL) 44 55 { _act = act; _usp = usp; } 45 56 57 //! Call this method to activate the stop/exit handler on signal \b sig 58 static void ActivateExitOnSignal(int sig=SIGUSR1); 46 59 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 */ 47 65 static inline void setCancelState(int st= PTHREAD_CANCEL_ENABLE) 48 66 { int ocs; pthread_setcancelstate(st, &ocs); } 49 67 // 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 */ 50 74 static inline void setCancelType(int ct= PTHREAD_CANCEL_DEFERRED) 51 75 { int oct; pthread_setcanceltype(ct, &oct); } 52 76 // PTHREAD_CANCEL_DEFERRED ou PTHREAD_CANCEL_ASYNCHRONOUS 53 77 78 virtual void run_p(); 54 79 55 80 // ---- Attribute variables ---- … … 57 82 size_t _ssize; 58 83 int _rc; 59 bool _initok;84 int _status; // 0 : not started, 1: running, 2: ended, 3:stopped 60 85 61 86 ZThreadAction _act;
Note:
See TracChangeset
for help on using the changeset viewer.