} 274 } 275 276 pointer address(reference x) { return (pointer)&x; } 277 278 size_type max_size() throw() 279 { return (static_cast(-1) / sizeof(T)) >> 6; } 280 281 void destroy(pointer p) throw() { p->~T(); } 282 283 void construct(pointer p, const T& val) 284 { ::new((void*)p) T(val); } 285 286 }; 287 288 template 289 bitmap_fixed_size_allocator single_object_allocator:: 290 bm(sizeof(T), (static_cast(-1) / sizeof(T)) >> 6); 291 292 293 template 294 inline bool operator ==(const single_object_allocator&, const single_object_allocator&) 295 { return true; } 296 297 template 298 inline bool operator ==(const single_object_allocator&, const single_object_allocator&) 299 { return true; } 300 301 template 302 inline bool operator !=(const single_object_allocator&, const single_object_allocator&) 303 { return false; } 304 305 template 306 inline bool operator !=(const single_object_allocator&, const single_object_allocator&) 307 { return false; } 308 309 310 #endif /// SINGLE_OBJECT_ALLOCATOR_HPP_ 1 // Code copied from boost with minor changes by Chipset 2 3 // Copyright (C) 2000 Stephen Cleary 4 // 5 // Distributed under the Boost Software License, Version 1.0. (See 6 // accompanying file LICENSE_1_0.txt or copy at 7 // http://www.boost.org/LICENSE_1_0.txt) 8 // 9 // See http://www.boost.org for updates, documentation, and revision history. 10 11 #ifndef ALLOCATOR_MUTEX_HPP_ 12 #define ALLOCATOR_MUTEX_HPP_ 13 14 // Light-Weight wrapper classes for OS thread 15 16 17 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) || defined(__MINGW32__) 18 #include 19 #endif 20 21 #if defined(_POSIX_THREADS) 22 #include 23 #endif 24 25 26 // Some compatible macros on Windows system 27 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) || defined(__MINGW32__) 28 // How about on Win64 Sorry, I do not know which API to bind yet. 29 30 class win32_mutex 31 { 32 private: 33 ::CRITICAL_SECTION mtx; 34 win32_mutex(const win32_mutex&); 35 void operator =(const win32_mutex&); 36 public: 37 win32_mutex() { ::InitializeCriticalSection(&mtx); } 38 ~win32_mutex() { ::DeleteCriticalSection(&mtx); } 39 void lock() { ::EnterCriticalSection(&mtx); } 40 void unlock() { ::LeaveCriticalSection(&mtx); } 41 }; 42 43 typedef win32_mutex default_mutex; 44 45 #elif defined(_POSIX_THREADS) 46 47 class pthread_mutex 48 { 49 private: 50 ::pthread_mutex_t mtx; 51 pthread_mutex(const pthread_mutex&); 52 void operator =(const pthread_mutex&); 53 public: 54 pthread_mutex() { ::pthread_mutex_init(&mtx, 0); } 55 ~pthread_mutex() { ::pthread_mutex_destroy(&mtx); } 56 void lock() { ::pthread_mutex_lock(&mtx); } 57 void unlock() { ::pthread_mutex_unlock(&mtx); } 58 }; 59 60 typedef pthread_mutex default_mutex; 61 62 #else // defined(_POSIX_THREADS) 63 64 65 class null_mutex 66 { 67 private: 68 null_mutex(const null_mutex &); 69 void operator =(const null_mutex&); 70 public: 71 null_mutex() {} 72 static void lock() {} 73 static void unlock() {} 74 }; 75 76 typedef null_mutex default_mutex; 77 78 #endif 79 80 81 #endif 1 // Code copied from boost with minor changes by Chipset 2 3 // Copyright (C) 2000 Stephen Cleary 4 // 5 // Distributed under the Boost Software License, Version 1.0. (See 6 // accompanying file LICENSE_1_0.txt or copy at 7 // http://www.boost.org/LICENSE |