tmp/tmpxapup1vz/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### General <a id="mem.res.monotonic.buffer.general">[[mem.res.monotonic.buffer.general]]</a>
|
| 2 |
+
|
| 3 |
+
A `monotonic_buffer_resource` is a special-purpose memory resource
|
| 4 |
+
intended for very fast memory allocations in situations where memory is
|
| 5 |
+
used to build up a few objects and then is released all at once when the
|
| 6 |
+
memory resource object is destroyed.
|
| 7 |
+
|
| 8 |
+
``` cpp
|
| 9 |
+
namespace std::pmr {
|
| 10 |
+
class monotonic_buffer_resource : public memory_resource {
|
| 11 |
+
memory_resource* upstream_rsrc; // exposition only
|
| 12 |
+
void* current_buffer; // exposition only
|
| 13 |
+
size_t next_buffer_size; // exposition only
|
| 14 |
+
|
| 15 |
+
public:
|
| 16 |
+
explicit monotonic_buffer_resource(memory_resource* upstream);
|
| 17 |
+
monotonic_buffer_resource(size_t initial_size, memory_resource* upstream);
|
| 18 |
+
monotonic_buffer_resource(void* buffer, size_t buffer_size, memory_resource* upstream);
|
| 19 |
+
|
| 20 |
+
monotonic_buffer_resource()
|
| 21 |
+
: monotonic_buffer_resource(get_default_resource()) {}
|
| 22 |
+
explicit monotonic_buffer_resource(size_t initial_size)
|
| 23 |
+
: monotonic_buffer_resource(initial_size, get_default_resource()) {}
|
| 24 |
+
monotonic_buffer_resource(void* buffer, size_t buffer_size)
|
| 25 |
+
: monotonic_buffer_resource(buffer, buffer_size, get_default_resource()) {}
|
| 26 |
+
|
| 27 |
+
monotonic_buffer_resource(const monotonic_buffer_resource&) = delete;
|
| 28 |
+
|
| 29 |
+
virtual ~monotonic_buffer_resource();
|
| 30 |
+
|
| 31 |
+
monotonic_buffer_resource& operator=(const monotonic_buffer_resource&) = delete;
|
| 32 |
+
|
| 33 |
+
void release();
|
| 34 |
+
memory_resource* upstream_resource() const;
|
| 35 |
+
|
| 36 |
+
protected:
|
| 37 |
+
void* do_allocate(size_t bytes, size_t alignment) override;
|
| 38 |
+
void do_deallocate(void* p, size_t bytes, size_t alignment) override;
|
| 39 |
+
|
| 40 |
+
bool do_is_equal(const memory_resource& other) const noexcept override;
|
| 41 |
+
};
|
| 42 |
+
}
|
| 43 |
+
```
|
| 44 |
+
|