Stxxl 1.2.1
|
00001 /*************************************************************************** 00002 * include/stxxl/bits/common/debug.h 00003 * 00004 * Part of the STXXL. See http://stxxl.sourceforge.net 00005 * 00006 * Copyright (C) 2004 Roman Dementiev <dementiev@ira.uka.de> 00007 * 00008 * Distributed under the Boost Software License, Version 1.0. 00009 * (See accompanying file LICENSE_1_0.txt or copy at 00010 * http://www.boost.org/LICENSE_1_0.txt) 00011 **************************************************************************/ 00012 00013 #ifndef STXXL_DEBUG_HEADER 00014 #define STXXL_DEBUG_HEADER 00015 00016 #ifdef STXXL_BOOST_CONFIG 00017 #include <boost/config.hpp> 00018 #endif 00019 00020 #include <stxxl/bits/namespace.h> 00021 #include <stxxl/bits/singleton.h> 00022 #include <stxxl/bits/common/mutex.h> 00023 #include <stxxl/bits/compat_hash_map.h> 00024 00025 00026 __STXXL_BEGIN_NAMESPACE 00027 00028 #ifdef STXXL_DEBUGMON 00029 #define STXXL_DEBUGMON_DO(action) debugmon::get_instance()->action 00030 #else 00031 #define STXXL_DEBUGMON_DO(action) 00032 #endif 00033 00034 class debugmon : public singleton<debugmon> 00035 { 00036 friend class singleton<debugmon>; 00037 00038 #ifdef STXXL_DEBUGMON 00039 00040 struct tag 00041 { 00042 bool ongoing; 00043 char * end; 00044 size_t size; 00045 }; 00046 struct hash_fct 00047 { 00048 inline size_t operator () (char * arg) const 00049 { 00050 return long(arg); 00051 } 00052 #ifdef BOOST_MSVC 00053 bool operator () (char * a, char * b) const 00054 { 00055 return (long(a) < long(b)); 00056 } 00057 enum 00058 { // parameters for hash table 00059 bucket_size = 4, // 0 < bucket_size 00060 min_buckets = 8 // min_buckets = 2 ^^ N, 0 < N 00061 }; 00062 #endif 00063 }; 00064 00065 compat_hash_map<char *, tag, hash_fct>::result tags; 00066 00067 mutex mutex1; 00068 00069 #endif // #ifdef STXXL_DEBUGMON 00070 00071 public: 00072 void block_allocated(char * ptr, char * end, size_t size); 00073 void block_deallocated(char * ptr); 00074 void io_started(char * ptr); 00075 void io_finished(char * ptr); 00076 }; 00077 00078 __STXXL_END_NAMESPACE 00079 00080 #endif // !STXXL_DEBUG_HEADER