Changeset 3718 in Sophya for trunk/SophyaLib/SysTools/zthread.h
- Timestamp:
- Dec 28, 2009, 10:05:51 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/SysTools/zthread.h
r3586 r3718 31 31 explicit ZThread(size_t stacksize=0); 32 32 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 33 38 void start(); 34 39 void cancel(); 35 40 void kill(int sig); 41 void join(); 36 42 37 void join();38 43 virtual void run(); 39 44 40 45 //! 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); } 42 47 //! Returns true if the thread is running 43 bool IfRunning() { return ((_status == 1) ? true : false); }48 bool IfRunning() { return ((_status == 2) ? true : false); } 44 49 //! Returns true if the thread has ended normally 45 bool IfEnded() { return ((_status == 2) ? true : false); }50 bool IfEnded() { return ((_status == 3) ? true : false); } 46 51 //! 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); } 48 53 49 54 //! Sets the return code for the thread object … … 77 82 // PTHREAD_CANCEL_DEFERRED ou PTHREAD_CANCEL_ASYNCHRONOUS 78 83 84 /*! 85 \brief This method is only for internal use by zthread.cc and should not be called by users 86 */ 79 87 virtual void run_p(); 80 88 … … 83 91 size_t _ssize; 84 92 int _rc; 85 int _status; // 0 : not started, 1 : running, 2: ended, 3:stopped86 93 int _status; // 0 : not started, 1 : started, 2: running, 3: ended, 5:stopped 94 bool _fgstarted; // false -> true par appel a start() 87 95 ZThreadAction _act; 88 96 void * _usp;
Note:
See TracChangeset
for help on using the changeset viewer.