acl  3.5.3.0
dbuf_allocator.hpp
浏览该文件的文档.
1 #pragma once
2 
3 #include <memory>
4 #include "dbuf_pool.hpp"
5 
6 namespace acl {
7 
8 template <typename T>
9 class dbuf_allocator : public std::allocator<T> {
10 public:
11  typedef size_t size_type;
17 
18  pointer allocate(size_type _Count, const void* _Hint = NULL) {
19  (void) _Hint;
20  pointer p = (pointer) dbuf_.dbuf_alloc(_Count * sizeof(T));
21  return p;
22  }
23 
24  void deallocate(pointer _Ptr, size_type _Count) {
25  (void) _Ptr;
26  (void) _Count;
27  }
28 
29  template<class _Other>
30  struct rebind {
31  // convert this type to allocator<_Other>
33  };
34 
35  dbuf_allocator(void) throw() {}
36 
37  dbuf_allocator(const dbuf_allocator& __a) throw()
38  : std::allocator<T> (__a) {
39  (void) __a;
40  }
41 
42  template<typename _Tp1>
44 
45  ~dbuf_allocator(void) throw() {}
46 
47 private:
48  dbuf_guard dbuf_;
49 };
50 
51 } // namespace acl
dbuf_allocator< T >::const_pointer const_pointer
pointer allocate(size_type _Count, const void *_Hint=NULL)
dbuf_allocator< T >::const_reference const_reference
dbuf_allocator< T >::reference reference
dbuf_allocator(const dbuf_allocator< _Tp1 > &)
void * dbuf_alloc(size_t len)
Definition: dbuf_pool.hpp:246
void deallocate(pointer _Ptr, size_type _Count)
dbuf_allocator< T >::pointer pointer
dbuf_allocator< _Other > other
dbuf_allocator< T >::value_type value_type
dbuf_allocator(const dbuf_allocator &__a)