Ticket #4960: singleton_pool.hpp.patch
File singleton_pool.hpp.patch, 1.9 KB (added by , 12 years ago) |
---|
-
boost/pool/singleton_pool.hpp
18 18 // boost::details::pool::guard 19 19 #include <boost/pool/detail/guard.hpp> 20 20 21 #include <boost/units/detail/utility.hpp> 22 #include <iostream> 23 #include <set> 24 21 25 namespace boost { 22 26 27 inline int get_id() { 28 static int result = 0; 29 return result++; 30 } 31 23 32 // 24 33 // The singleton_pool class allows other pool interfaces for types of the same 25 34 // size to share the same pool … … 64 73 details::pool::guard<Mutex> g(p); 65 74 return p.p.ordered_malloc(); 66 75 } 76 static int id() { static int result = get_id(); return result; } 67 77 static void * ordered_malloc(const size_type n) 68 78 { 69 79 pool_type & p = singleton::instance(); 70 80 details::pool::guard<Mutex> g(p); 71 return p.p.ordered_malloc(n); 81 82 static bool is_typedefed = false; 83 if(!is_typedefed) { 84 is_typedefed = true; 85 std::cout << "typedef " << boost::units::detail::demangle(typeid(singleton_pool).name()) 86 << "pool_type" << id() << ";\n"; 87 } 88 std::cout << "tmp = pool_type" << id() << "::ordered_malloc(" << n << ");" << std::endl; 89 void* result = p.p.ordered_malloc(n); 90 static std::set<void*> known; 91 if(known.insert(result).second) { 92 std::cout << "void* "; 93 } 94 std::cout << "p" << result << " = tmp;\n"; 95 return result; 72 96 } 73 97 static bool is_from(void * const ptr) 74 98 { … … 98 122 { 99 123 pool_type & p = singleton::instance(); 100 124 details::pool::guard<Mutex> g(p); 125 std::cout << "pool_type" << id() << "::ordered_free(p" << ptr << ", " << n << ");" << std::endl; 101 126 p.p.ordered_free(ptr, n); 102 127 } 103 128 static bool release_memory()