source: tbroadcast/v1/src/TCmThread.hxx @ 231

Last change on this file since 231 was 231, checked in by garonne, 18 years ago

import tbroadcast

File size: 953 bytes
Line 
1#ifndef __TCmThread_hxx__
2#define __TCmThread_hxx__
3
4#include <string>
5
6class TCmThread
7{
8public:
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
19protected:
20  static void run_it (TCmThread* thread);
21  long _thread_id;
22  bool _running;
23  bool _should_die;
24
25private:
26  static void do_cleanup (void* thread);
27};
28
29class TCmMutex
30{
31public:
32  static void iolock ();
33  static void iounlock ();
34
35public:
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
45private:
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.