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

libcwd/private_mutex.h

Go to the documentation of this file.
00001 // $Header: /cvsroot/libcwd/libcwd/include/libcwd/private_mutex.h,v 1.4 2004/05/27 03:03:53 libcw Exp $
00002 //
00003 // Copyright (C) 2002 - 2003, by
00004 //
00005 // Carlo Wood, Run on IRC <carlo@alinoe.com>
00006 // RSA-1024 0x624ACAD5 1997-01-26                    Sign & Encrypt
00007 // Fingerprint16 = 32 EC A7 B6 AC DB 65 A6  F6 F6 55 DD 1C DC FF 61
00008 //
00009 // This file may be distributed under the terms of the Q Public License
00010 // version 1.0 as appearing in the file LICENSE.QPL included in the
00011 // packaging of this file.
00012 // 
00013 
00018 #ifndef LIBCWD_PRIVATE_MUTEX_H
00019 #define LIBCWD_PRIVATE_MUTEX_H
00020 
00021 #ifndef LIBCW_PTHREAD_H
00022 #define LIBCW_PTHREAD_H
00023 #include <pthread.h>
00024 #endif
00025 
00026 namespace libcwd {
00027   namespace _private_ {
00028 #if CWDEBUG_DEBUGT
00029     struct TSD_st;
00030 #endif
00031 
00032 class mutex_ct {
00033 private:
00034   pthread_mutex_t M_mutex;
00035 public:
00036 #if CWDEBUG_DEBUG || CWDEBUG_DEBUGT
00037   int M_instance_locked;
00038 #endif
00039 #if CWDEBUG_DEBUGT
00040   pthread_t M_locked_by;
00041   void const* M_locked_from;
00042 #endif
00043 protected:
00044   bool M_initialized;
00045   void M_initialize(void);
00046 public:
00047   void initialize(void);
00048 public:
00049   bool trylock(void);
00050   void lock(void);
00051   void unlock(void);
00052 #if CWDEBUG_DEBUGT
00053   bool trylock(TSD_st&);
00054   void lock(TSD_st&);
00055   void unlock(TSD_st&);
00056 #endif
00057 #if CWDEBUG_DEBUG || CWDEBUG_DEBUGT
00058   bool is_locked(void);
00059 #endif
00060 };
00061 
00062   } // namespace _private_
00063 } // namespace libcwd
00064 
00065 #endif // LIBCWD_PRIVATE_MUTEX_H
00066 
Copyright © 2001 - 2004 Carlo Wood.  All rights reserved.