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

private_lock_interface.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_LOCK_INTERFACE_H
19 #define LIBCWD_PRIVATE_LOCK_INTERFACE_H
20 
21 #if LIBCWD_THREAD_SAFE
22 namespace libcwd {
23  namespace _private_ {
24 
25 class lock_interface_base_ct {
26 public:
27  virtual int try_lock() = 0;
28  virtual void lock() = 0;
29  virtual void unlock() = 0;
30  virtual ~lock_interface_base_ct() { }
31 };
32 
33 template<class T>
34  class lock_interface_tct : public lock_interface_base_ct {
35  private:
36  T* ptr;
37  virtual int try_lock() { return ptr->try_lock(); }
38  virtual void lock() { ptr->lock(); }
39  virtual void unlock() { ptr->unlock(); }
40  public:
41  lock_interface_tct(T* mutex) : ptr(mutex) { }
42  };
43 
44 class pthread_lock_interface_ct : public lock_interface_base_ct {
45  private:
46  pthread_mutex_t* ptr;
47  virtual int try_lock();
48  virtual void lock();
49  virtual void unlock();
50  public:
51  pthread_lock_interface_ct(pthread_mutex_t* mutex) : ptr(mutex) { }
52 };
53 
54  } // namespace _private_
55 } // namespace libcwd
56 
57 #endif // LIBCWD_THREAD_SAFE
58 #endif // LIBCWD_PRIVATE_LOCK_INTERFACE_H
59 
namespace for libcwd.
Definition: debug.cc:87
Copyright © 2001 - 2004 Carlo Wood.  All rights reserved.