pool_allocator.h Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
pool_allocator.h
Go to the documentation of this file.
1 /* pool_allocator.h
2 */
3 #ifndef OSL_POOL_ALLOCATOR_H
4 #define OSL_POOL_ALLOCATOR_H
5
6 #ifdef USE_TBB_SCALABLE_ALLOCATOR
7 # include <tbb/scalable_allocator.h>
8 #endif
9 #ifdef USE_BOOST_POOL_ALLOCATOR
10 # include "osl/misc/lightMutex.h"
11 # include <boost/pool/pool_alloc.hpp>
12 # include <boost/mpl/if.hpp>
13 #else
14 # include <memory>
15 #endif
16
17 namespace osl
18 {
27 namespace stl
28 {
29 extern const int pool_allocator_type;
30 struct ConsistencyCheck
31 {
32 ConsistencyCheck(int);
33 };
34 #ifdef USE_TBB_SCALABLE_ALLOCATOR
35 static ConsistencyCheck consistency_check(-1);
36 template <class T>
37 struct pool_allocator : tbb::scalable_allocator<T>
38 {
39 pool_allocator() {}
40 template <class T2>
41 pool_allocator(const tbb::scalable_allocator<T2>& src) : tbb::scalable_allocator<T>(src) {}
42 };
43 #elif USE_BOOST_POOL_ALLOCATOR
44 static ConsistencyCheck consistency_check(2);
45 template <class T>
46 struct fast_pool_allocator
47 : boost::mpl::if_c<(sizeof(T) <= 128),
48 boost::fast_pool_allocator
49 <T,
50 boost::default_user_allocator_new_delete,
51 osl::LightMutex,
52 128*65536/sizeof(T)+1
53 >,
54 std::allocator<T> >::type
55 {
56 fast_pool_allocator() {}
57 template <class T2, class T3, class T4, unsigned int U>
58 fast_pool_allocator(const boost::fast_pool_allocator<T2,T3,T4,U>& src) {}
59 template <class T2>
60 fast_pool_allocator(const std::allocator<T2>& src) {}
61 };
62 template <class T>
63 struct pool_allocator : std::allocator<T>
64 {
65 pool_allocator() {}
66 template <class T2>
67 pool_allocator(const std::allocator<T2>&) {}
68 };
69 #else
70 static ConsistencyCheck consistency_check(0);
71 template <class T>
72 struct pool_allocator : std::allocator<T>
73 {
74 pool_allocator() {}
75 template <class T2>
76 pool_allocator(const std::allocator<T2>&) {}
77 };
78 #endif
79 } // namespace stl
80 } // namespace osl
81
82 #endif /* OSL_POOL_ALLOCATOR_H */
83 // ;;; Local Variables:
84 // ;;; mode:c++
85 // ;;; c-basic-offset:2
86 // ;;; End: