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

libcwd/private_mutex_instances.h

Go to the documentation of this file.
00001 // $Header$
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   backtrace_instance,
00061   write_max_len_instance,
00062   set_ostream_instance,
00063   kill_threads_instance,
00064   function_instance,
00065   // Values reserved for read/write locks.
00066   reserved_instance_low,
00067   reserved_instance_high = 3 * reserved_instance_low,
00068   // Values reserved for test executables.
00069   test_instance0 = reserved_instance_high,
00070   test_instance1,
00071   test_instance2,
00072   test_instance3,
00073   instance_locked_size                  // Must be last in list
00074 };
00075 
00076 #if CWDEBUG_DEBUG || CWDEBUG_DEBUGT
00077 extern int instance_locked[instance_locked_size];       // MT: Each element is locked by the
00078 inline bool is_locked(int instance) { return instance_locked[instance] > 0; }
00079 #endif
00080 #if CWDEBUG_DEBUGT
00081 extern pthread_t locked_by[instance_locked_size];       // The id of the thread that last locked it, or 0 when that thread unlocked it.
00082 extern void const* locked_from[instance_locked_size];   // and where is was locked.
00083 size_t const read_lock_offset = instance_locked_size;
00084 size_t const high_priority_read_lock_offset = 2 * instance_locked_size;
00085 #endif
00086 
00087   } // namespace _private_
00088 } // namespace libcwd
00089 
00090 #endif // LIBCWD_THREAD_SAFE
00091 #endif // LIBCWD_PRIVATE_MUTEX_INSTANCES_H
00092 
Copyright © 2001 - 2004 Carlo Wood.  All rights reserved.