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

/usr/src/libcwd/libcwd/include/libcwd/private_mutex_instances.h

Go to the documentation of this file.
00001 // $Header: /cvsroot/libcwd/libcwd/include/libcwd/private_mutex_instances.h,v 1.9 2004/07/14 00:29:35 libcw Exp $
00002 //
00003 // Copyright (C) 2001 - 2004, 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_INSTANCES_H
00019 #define LIBCWD_PRIVATE_MUTEX_INSTANCES_H
00020 
00021 #if LIBCWD_THREAD_SAFE
00022 
00023 #if CWDEBUG_DEBUGT
00024 #ifndef LIBCW_PTHREAD_H
00025 #define LIBCW_PTHREAD_H
00026 #include <pthread.h>
00027 #endif
00028 #endif
00029 
00030 namespace libcwd {
00031   namespace _private_ {
00032 
00033 // The different instance-ids used in libcwd.
00034 enum mutex_instance_nt {
00035   // Recursive mutexes.
00036   static_tsd_instance,
00037   object_files_instance,                // rwlock
00038   end_recursive_types,
00039   // Fast mutexes.
00040 #if CWDEBUG_ALLOC
00041   memblk_map_instance,
00042   location_cache_instance,              // rwlock
00043 #endif
00044   threadlist_instance,                  // rwlock
00045   debug_objects_instance,               // rwlock
00046   debug_channels_instance,              // rwlock
00047 #if CWDEBUG_DEBUGT
00048   keypair_map_instance,
00049   pthread_lock_interface_instance,      // Dummy instance that is used to store who locked the ostream.
00050   instance_rdlocked_size,               // Must come after last rwlock and pthread_lock_interface_instance.
00051 #endif
00052   mutex_initialization_instance,
00053   ids_singleton_tct_S_ids_instance,
00054 #if CWDEBUG_ALLOC
00055   alloc_tag_desc_instance,
00056   list_allocations_instance,
00057 #endif
00058   dlopen_map_instance,
00059   dlclose_instance,
00060   write_max_len_instance,
00061   set_ostream_instance,
00062   kill_threads_instance,
00063   function_instance,
00064   // Values reserved for read/write locks.
00065   reserved_instance_low,
00066   reserved_instance_high = 3 * reserved_instance_low,
00067   // Values reserved for test executables.
00068   test_instance0 = reserved_instance_high,
00069   test_instance1,
00070   test_instance2,
00071   test_instance3,
00072   instance_locked_size                  // Must be last in list
00073 };
00074 
00075 #if CWDEBUG_DEBUG || CWDEBUG_DEBUGT
00076 extern int instance_locked[instance_locked_size];       // MT: Each element is locked by the
00077 inline bool is_locked(int instance) { return instance_locked[instance] > 0; }
00078 #endif
00079 #if CWDEBUG_DEBUGT
00080 extern pthread_t locked_by[instance_locked_size];       // The id of the thread that last locked it, or 0 when that thread unlocked it.
00081 extern void const* locked_from[instance_locked_size];   // and where is was locked.
00082 int const read_lock_offset = instance_locked_size;
00083 int const high_priority_read_lock_offset = 2 * instance_locked_size;
00084 #endif
00085 
00086   } // namespace _private_
00087 } // namespace libcwd
00088 
00089 #endif // LIBCWD_THREAD_SAFE
00090 #endif // LIBCWD_PRIVATE_MUTEX_INSTANCES_H
00091 
Copyright © 2001 - 2004 Carlo Wood.  All rights reserved.