PoolingAllocator.h
Go to the documentation of this file.
1 /*
2 + * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
3 + *
4 + * Squid software is distributed under GPLv2+ license and includes
5 + * contributions from numerous individuals and organizations.
6 + * Please see the COPYING and CONTRIBUTORS files for details.
7 + */
8 
9 #ifndef SQUID_MEM_POOLINGALLOCATOR_H
10 #define SQUID_MEM_POOLINGALLOCATOR_H
11 
12 #include "mem/forward.h"
13 
15 template <class Value>
17 {
18 public:
19  /* STL Allocator API */
20  using value_type = Value;
21  PoolingAllocator() noexcept {}
22  template <class Other> PoolingAllocator(const PoolingAllocator<Other> &) noexcept {}
23  value_type *allocate(std::size_t n) { return static_cast<value_type*>(memAllocRigid(n*sizeof(value_type))); }
24  void deallocate(value_type *vp, std::size_t n) noexcept { memFreeRigid(vp, n*sizeof(value_type)); }
25 
26  // The following declarations are only necessary for compilers that do not
27  // fully support C++11 Allocator-related APIs, such as GCC v4.8.
28  // The corresponding std::allocator declarations are deprecated in C++17.
29  // TODO: Remove after dropping support for deficient compilers.
30 
31  using size_type = size_t;
32  using pointer = Value*;
33  using const_pointer = const Value*;
34  using reference = Value&;
35  using const_reference = const Value&;
36 
37  template <class OtherValue>
38  struct rebind {
40  };
41 
42  template<class U, class ... Args> void construct(U *p, Args && ... args) { new((void *)p) U(std::forward<Args>(args)...); }
43  template<typename OtherValue> void destroy(OtherValue *p) { p->~OtherValue(); }
44 };
45 
46 template <class L, class R>
47 inline bool
49 {
50  return true;
51 }
52 
53 template <class L, class R>
54 inline bool
56 {
57  return !(l == r);
58 }
59 
60 #endif /* SQUID_MEM_POOLINGALLOCATOR_H */
61 
const Value & const_reference
void * memAllocRigid(size_t net_size)
Definition: old_api.cc:249
const Value * const_pointer
bool operator==(const PoolingAllocator< L > &, const PoolingAllocator< R > &) noexcept
int const char size_t
Definition: stub_liblog.cc:86
PoolingAllocator(const PoolingAllocator< Other > &) noexcept
void memFreeRigid(void *, size_t net_size)
Definition: old_api.cc:291
PoolingAllocator< OtherValue > other
STL Allocator that uses Squid memory pools for memory management.
value_type * allocate(std::size_t n)
void destroy(OtherValue *p)
bool operator!=(const PoolingAllocator< L > &l, const PoolingAllocator< R > &r) noexcept
void construct(U *p, Args &&... args)
PoolingAllocator() noexcept
void deallocate(value_type *vp, std::size_t n) noexcept

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors