From Jason Turner

[mem.res.pool]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp2h45po2a/{from.md → to.md} +17 -28
tmp/tmp2h45po2a/{from.md → to.md} RENAMED
@@ -32,19 +32,19 @@ without external synchronization and may have thread-specific pools to
32
  reduce synchronization costs. An `unsynchronized_pool_resource` class
33
  may not be accessed from multiple threads simultaneously and thus avoids
34
  the cost of synchronization entirely in single-threaded applications.
35
 
36
  ``` cpp
 
37
  struct pool_options {
38
  size_t max_blocks_per_chunk = 0;
39
  size_t largest_required_pool_block = 0;
40
  };
41
 
42
  class synchronized_pool_resource : public memory_resource {
43
  public:
44
- synchronized_pool_resource(const pool_options& opts,
45
- memory_resource* upstream);
46
 
47
  synchronized_pool_resource()
48
  : synchronized_pool_resource(pool_options(), get_default_resource()) {}
49
  explicit synchronized_pool_resource(memory_resource* upstream)
50
  : synchronized_pool_resource(pool_options(), upstream) {}
@@ -52,12 +52,11 @@ public:
52
  : synchronized_pool_resource(opts, get_default_resource()) {}
53
 
54
  synchronized_pool_resource(const synchronized_pool_resource&) = delete;
55
  virtual ~synchronized_pool_resource();
56
 
57
- synchronized_pool_resource&
58
- operator=(const synchronized_pool_resource&) = delete;
59
 
60
  void release();
61
  memory_resource* upstream_resource() const;
62
  pool_options options() const;
63
 
@@ -68,12 +67,11 @@ protected:
68
  bool do_is_equal(const memory_resource& other) const noexcept override;
69
  };
70
 
71
  class unsynchronized_pool_resource : public memory_resource {
72
  public:
73
- unsynchronized_pool_resource(const pool_options& opts,
74
- memory_resource* upstream);
75
 
76
  unsynchronized_pool_resource()
77
  : unsynchronized_pool_resource(pool_options(), get_default_resource()) {}
78
  explicit unsynchronized_pool_resource(memory_resource* upstream)
79
  : unsynchronized_pool_resource(pool_options(), upstream) {}
@@ -81,12 +79,11 @@ public:
81
  : unsynchronized_pool_resource(opts, get_default_resource()) {}
82
 
83
  unsynchronized_pool_resource(const unsynchronized_pool_resource&) = delete;
84
  virtual ~unsynchronized_pool_resource();
85
 
86
- unsynchronized_pool_resource&
87
- operator=(const unsynchronized_pool_resource&) = delete;
88
 
89
  void release();
90
  memory_resource* upstream_resource() const;
91
  pool_options options() const;
92
 
@@ -94,10 +91,11 @@ protected:
94
  void* do_allocate(size_t bytes, size_t alignment) override;
95
  void do_deallocate(void* p, size_t bytes, size_t alignment) override;
96
 
97
  bool do_is_equal(const memory_resource& other) const noexcept override;
98
  };
 
99
  ```
100
 
101
  #### `pool_options` data members <a id="mem.res.pool.options">[[mem.res.pool.options]]</a>
102
 
103
  The members of `pool_options` comprise a set of constructor options for
@@ -107,11 +105,11 @@ is described below:
107
  ``` cpp
108
  size_t max_blocks_per_chunk;
109
  ```
110
 
111
  The maximum number of blocks that will be allocated at once from the
112
- upstream memory resource ([[mem.res.monotonic.buffer]]) to replenish a
113
  pool. If the value of `max_blocks_per_chunk` is zero or is greater than
114
  an *implementation-defined* limit, that limit is used instead. The
115
  implementation may choose to use a smaller value than is specified in
116
  this field and may use different values for different pools.
117
 
@@ -125,18 +123,18 @@ threshold will be allocated directly from the upstream memory resource.
125
  If `largest_required_pool_block` is zero or is greater than an
126
  *implementation-defined* limit, that limit is used instead. The
127
  implementation may choose a pass-through threshold larger than specified
128
  in this field.
129
 
130
- #### Pool resource constructors and destructors <a id="mem.res.pool.ctor">[[mem.res.pool.ctor]]</a>
131
 
132
  ``` cpp
133
  synchronized_pool_resource(const pool_options& opts, memory_resource* upstream);
134
  unsynchronized_pool_resource(const pool_options& opts, memory_resource* upstream);
135
  ```
136
 
137
- *Requires:* `upstream` is the address of a valid memory resource.
138
 
139
  *Effects:* Constructs a pool resource object that will obtain memory
140
  from `upstream` whenever the pool resource is unable to satisfy a memory
141
  request from its own internal data structures. The resulting object will
142
  hold a copy of `upstream`, but will not own the resource to which
@@ -158,11 +156,11 @@ virtual ~synchronized_pool_resource();
158
  virtual ~unsynchronized_pool_resource();
159
  ```
160
 
161
  *Effects:* Calls `release()`.
162
 
163
- #### Pool resource members <a id="mem.res.pool.mem">[[mem.res.pool.mem]]</a>
164
 
165
  ``` cpp
166
  void release();
167
  ```
168
 
@@ -192,14 +190,15 @@ rounded to unspecified granularity.
192
 
193
  ``` cpp
194
  void* do_allocate(size_t bytes, size_t alignment) override;
195
  ```
196
 
197
- *Returns:* A pointer to allocated storage
198
- ([[basic.stc.dynamic.deallocation]]) with a size of at least `bytes`.
199
- The size and alignment of the allocated memory shall meet the
200
- requirements for a class derived from `memory_resource` ([[mem.res]]).
 
201
 
202
  *Effects:* If the pool selected for a block of size `bytes` is unable to
203
  satisfy the memory request from its own internal data structures, it
204
  will call `upstream_resource()->allocate()` to obtain more memory. If
205
  `bytes` is larger than that which the largest pool can handle, then
@@ -216,20 +215,10 @@ or under what circumstances, this operation will result in a call to
216
  `upstream_resource()->deallocate()`.
217
 
218
  *Throws:* Nothing.
219
 
220
  ``` cpp
221
- bool synchronized_pool_resource::do_is_equal(
222
- const memory_resource& other) const noexcept override;
223
  ```
224
 
225
- *Returns:*
226
- `this == dynamic_cast<const synchronized_pool_resource*>(&other)`.
227
-
228
- ``` cpp
229
- bool unsynchronized_pool_resource::do_is_equal(
230
- const memory_resource& other) const noexcept override;
231
- ```
232
-
233
- *Returns:*
234
- `this == dynamic_cast<const unsynchronized_pool_resource*>(&other)`.
235
 
 
32
  reduce synchronization costs. An `unsynchronized_pool_resource` class
33
  may not be accessed from multiple threads simultaneously and thus avoids
34
  the cost of synchronization entirely in single-threaded applications.
35
 
36
  ``` cpp
37
+ namespace std::pmr {
38
  struct pool_options {
39
  size_t max_blocks_per_chunk = 0;
40
  size_t largest_required_pool_block = 0;
41
  };
42
 
43
  class synchronized_pool_resource : public memory_resource {
44
  public:
45
+ synchronized_pool_resource(const pool_options& opts, memory_resource* upstream);
 
46
 
47
  synchronized_pool_resource()
48
  : synchronized_pool_resource(pool_options(), get_default_resource()) {}
49
  explicit synchronized_pool_resource(memory_resource* upstream)
50
  : synchronized_pool_resource(pool_options(), upstream) {}
 
52
  : synchronized_pool_resource(opts, get_default_resource()) {}
53
 
54
  synchronized_pool_resource(const synchronized_pool_resource&) = delete;
55
  virtual ~synchronized_pool_resource();
56
 
57
+ synchronized_pool_resource& operator=(const synchronized_pool_resource&) = delete;
 
58
 
59
  void release();
60
  memory_resource* upstream_resource() const;
61
  pool_options options() const;
62
 
 
67
  bool do_is_equal(const memory_resource& other) const noexcept override;
68
  };
69
 
70
  class unsynchronized_pool_resource : public memory_resource {
71
  public:
72
+ unsynchronized_pool_resource(const pool_options& opts, memory_resource* upstream);
 
73
 
74
  unsynchronized_pool_resource()
75
  : unsynchronized_pool_resource(pool_options(), get_default_resource()) {}
76
  explicit unsynchronized_pool_resource(memory_resource* upstream)
77
  : unsynchronized_pool_resource(pool_options(), upstream) {}
 
79
  : unsynchronized_pool_resource(opts, get_default_resource()) {}
80
 
81
  unsynchronized_pool_resource(const unsynchronized_pool_resource&) = delete;
82
  virtual ~unsynchronized_pool_resource();
83
 
84
+ unsynchronized_pool_resource& operator=(const unsynchronized_pool_resource&) = delete;
 
85
 
86
  void release();
87
  memory_resource* upstream_resource() const;
88
  pool_options options() const;
89
 
 
91
  void* do_allocate(size_t bytes, size_t alignment) override;
92
  void do_deallocate(void* p, size_t bytes, size_t alignment) override;
93
 
94
  bool do_is_equal(const memory_resource& other) const noexcept override;
95
  };
96
+ }
97
  ```
98
 
99
  #### `pool_options` data members <a id="mem.res.pool.options">[[mem.res.pool.options]]</a>
100
 
101
  The members of `pool_options` comprise a set of constructor options for
 
105
  ``` cpp
106
  size_t max_blocks_per_chunk;
107
  ```
108
 
109
  The maximum number of blocks that will be allocated at once from the
110
+ upstream memory resource [[mem.res.monotonic.buffer]] to replenish a
111
  pool. If the value of `max_blocks_per_chunk` is zero or is greater than
112
  an *implementation-defined* limit, that limit is used instead. The
113
  implementation may choose to use a smaller value than is specified in
114
  this field and may use different values for different pools.
115
 
 
123
  If `largest_required_pool_block` is zero or is greater than an
124
  *implementation-defined* limit, that limit is used instead. The
125
  implementation may choose a pass-through threshold larger than specified
126
  in this field.
127
 
128
+ #### Constructors and destructors <a id="mem.res.pool.ctor">[[mem.res.pool.ctor]]</a>
129
 
130
  ``` cpp
131
  synchronized_pool_resource(const pool_options& opts, memory_resource* upstream);
132
  unsynchronized_pool_resource(const pool_options& opts, memory_resource* upstream);
133
  ```
134
 
135
+ *Preconditions:* `upstream` is the address of a valid memory resource.
136
 
137
  *Effects:* Constructs a pool resource object that will obtain memory
138
  from `upstream` whenever the pool resource is unable to satisfy a memory
139
  request from its own internal data structures. The resulting object will
140
  hold a copy of `upstream`, but will not own the resource to which
 
156
  virtual ~unsynchronized_pool_resource();
157
  ```
158
 
159
  *Effects:* Calls `release()`.
160
 
161
+ #### Members <a id="mem.res.pool.mem">[[mem.res.pool.mem]]</a>
162
 
163
  ``` cpp
164
  void release();
165
  ```
166
 
 
190
 
191
  ``` cpp
192
  void* do_allocate(size_t bytes, size_t alignment) override;
193
  ```
194
 
195
+ *Returns:* A pointer to allocated
196
+ storage [[basic.stc.dynamic.allocation]] with a size of at least
197
+ `bytes`. The size and alignment of the allocated memory shall meet the
198
+ requirements for a class derived from `memory_resource`
199
+ [[mem.res.class]].
200
 
201
  *Effects:* If the pool selected for a block of size `bytes` is unable to
202
  satisfy the memory request from its own internal data structures, it
203
  will call `upstream_resource()->allocate()` to obtain more memory. If
204
  `bytes` is larger than that which the largest pool can handle, then
 
215
  `upstream_resource()->deallocate()`.
216
 
217
  *Throws:* Nothing.
218
 
219
  ``` cpp
220
+ bool do_is_equal(const memory_resource& other) const noexcept override;
 
221
  ```
222
 
223
+ *Returns:* `this == &other`.
 
 
 
 
 
 
 
 
 
224