Main Page   Reference Manual   Namespace List   Compound List   Namespace Members   Compound Members   File Members  

private_mutex.h
Go to the documentation of this file.
1 // $Header$
2 //
3 // Copyright (C) 2002 - 2004, by
4 //
5 // Carlo Wood, Run on IRC <carlo@alinoe.com>
6 // RSA-1024 0x624ACAD5 1997-01-26 Sign & Encrypt
7 // Fingerprint16 = 32 EC A7 B6 AC DB 65 A6 F6 F6 55 DD 1C DC FF 61
8 //
9 // This file may be distributed under the terms of the Q Public License
10 // version 1.0 as appearing in the file LICENSE.QPL included in the
11 // packaging of this file.
12 //
13 
18 #ifndef LIBCWD_PRIVATE_MUTEX_H
19 #define LIBCWD_PRIVATE_MUTEX_H
20 
21 #ifndef LIBCW_PTHREAD_H
22 #define LIBCW_PTHREAD_H
23 #include <pthread.h>
24 #endif
25 
26 namespace libcwd {
27  namespace _private_ {
28 #if CWDEBUG_DEBUGT
29  struct TSD_st;
30 #endif
31 
32 class mutex_ct {
33 private:
34  pthread_mutex_t M_mutex;
35 public:
36 #if CWDEBUG_DEBUG || CWDEBUG_DEBUGT
37  int M_instance_locked;
38 #endif
39 #if CWDEBUG_DEBUGT
40  pthread_t M_locked_by;
41  void const* M_locked_from;
42 #endif
43 protected:
44  bool M_initialized;
45  void M_initialize(void);
46 public:
47  void initialize(void);
48 public:
49  bool trylock(void);
50  void lock(void);
51  void unlock(void);
52 #if CWDEBUG_DEBUGT
53  bool trylock(TSD_st&);
54  void lock(TSD_st&);
55  void unlock(TSD_st&);
56 #endif
57 #if CWDEBUG_DEBUG || CWDEBUG_DEBUGT
58  bool is_locked(void);
59 #endif
60 };
61 
62  } // namespace _private_
63 } // namespace libcwd
64 
65 #endif // LIBCWD_PRIVATE_MUTEX_H
66 
Copyright © 2001 - 2004 Carlo Wood.  All rights reserved.