Rev | Line | |
---|
[231] | 1 | #ifndef __TCmThread_hxx__ |
---|
| 2 | #define __TCmThread_hxx__ |
---|
| 3 | |
---|
| 4 | #include <string> |
---|
| 5 | |
---|
| 6 | class TCmThread |
---|
| 7 | { |
---|
| 8 | public: |
---|
| 9 | static void set_debug_level (int level); |
---|
| 10 | static int debug_level (); |
---|
| 11 | |
---|
| 12 | TCmThread (); |
---|
| 13 | virtual ~TCmThread (); |
---|
| 14 | bool start (); |
---|
| 15 | bool stop (); |
---|
| 16 | virtual void run (); |
---|
| 17 | virtual void cleanup (); |
---|
| 18 | |
---|
| 19 | protected: |
---|
| 20 | static void run_it (TCmThread* thread); |
---|
| 21 | long _thread_id; |
---|
| 22 | bool _running; |
---|
| 23 | bool _should_die; |
---|
| 24 | |
---|
| 25 | private: |
---|
| 26 | static void do_cleanup (void* thread); |
---|
| 27 | }; |
---|
| 28 | |
---|
| 29 | class TCmMutex |
---|
| 30 | { |
---|
| 31 | public: |
---|
| 32 | static void iolock (); |
---|
| 33 | static void iounlock (); |
---|
| 34 | |
---|
| 35 | public: |
---|
| 36 | TCmMutex (); |
---|
| 37 | TCmMutex (const std::string& info); |
---|
| 38 | ~TCmMutex (); |
---|
| 39 | void set_info (const std::string& info); |
---|
| 40 | bool trylock (const std::string& info = ""); |
---|
| 41 | void lock (const std::string& info = ""); |
---|
| 42 | void unlock (); |
---|
| 43 | std::string show () const; |
---|
| 44 | |
---|
| 45 | private: |
---|
| 46 | static TCmMutex& get_iolock (); |
---|
| 47 | void initialize (); |
---|
| 48 | |
---|
| 49 | void* _mutex; |
---|
| 50 | std::string m_info; |
---|
| 51 | std::string m_context; |
---|
| 52 | int m_count; |
---|
| 53 | }; |
---|
| 54 | |
---|
| 55 | #endif |
---|
| 56 | |
---|
Note: See
TracBrowser
for help on using the repository browser.