00001
00002
00003 #ifndef OSL_POOL_ALLOCATOR_H
00004 #define OSL_POOL_ALLOCATOR_H
00005
00006 #ifdef USE_TBB_SCALABLE_ALLOCATOR
00007 # include <tbb/scalable_allocator.h>
00008 #endif
00009 #ifdef USE_BOOST_POOL_ALLOCATOR
00010 # include "osl/misc/lightMutex.h"
00011 # include <boost/pool/pool_alloc.hpp>
00012 # include <boost/mpl/if.hpp>
00013 #else
00014 # include <memory>
00015 #endif
00016
00017 namespace osl
00018 {
00027 namespace stl
00028 {
00029 extern const int pool_allocator_type;
00030 struct ConsistencyCheck
00031 {
00032 ConsistencyCheck(int);
00033 };
00034 #ifdef USE_TBB_SCALABLE_ALLOCATOR
00035 static ConsistencyCheck consistency_check(-1);
00036 template <class T>
00037 struct pool_allocator : tbb::scalable_allocator<T>
00038 {
00039 pool_allocator() {}
00040 template <class T2>
00041 pool_allocator(const tbb::scalable_allocator<T2>& src) : tbb::scalable_allocator<T>(src) {}
00042 };
00043 #elif USE_BOOST_POOL_ALLOCATOR
00044 static ConsistencyCheck consistency_check(2);
00045 template <class T>
00046 struct fast_pool_allocator
00047 : boost::mpl::if_c<(sizeof(T) <= 128),
00048 boost::fast_pool_allocator
00049 <T,
00050 boost::default_user_allocator_new_delete,
00051 osl::LightMutex,
00052 128*65536/sizeof(T)+1
00053 >,
00054 std::allocator<T> >::type
00055 {
00056 fast_pool_allocator() {}
00057 template <class T2, class T3, class T4, unsigned int U>
00058 fast_pool_allocator(const boost::fast_pool_allocator<T2,T3,T4,U>& src) {}
00059 template <class T2>
00060 fast_pool_allocator(const std::allocator<T2>& src) {}
00061 };
00062 template <class T>
00063 struct pool_allocator : std::allocator<T>
00064 {
00065 pool_allocator() {}
00066 template <class T2>
00067 pool_allocator(const std::allocator<T2>&) {}
00068 };
00069 #else
00070 static ConsistencyCheck consistency_check(0);
00071 template <class T>
00072 struct pool_allocator : std::allocator<T>
00073 {
00074 pool_allocator() {}
00075 template <class T2>
00076 pool_allocator(const std::allocator<T2>&) {}
00077 };
00078 #endif
00079 }
00080 }
00081
00082 #endif
00083
00084
00085
00086