5#ifndef WPINET_UV_BUFFER_H_
6#define WPINET_UV_BUFFER_H_
11#include <initializer_list>
39 len =
static_cast<decltype(
len)
>(len_);
41 Buffer(
const char* base_,
size_t len_) {
42 base =
const_cast<char*
>(base_);
43 len =
static_cast<decltype(
len)
>(len_);
49 operator std::span<const char>()
const {
return data(); }
50 operator std::span<char>() {
return data(); }
56 std::memcpy(buf.
base, in.data(), in.size());
62 std::memcpy(buf.
base, in.data(), in.size());
98template <
size_t DEPTH = 4>
115 if (m_pool.empty()) {
118 auto buf = m_pool.back();
135 for (
auto& buf : bufs) {
136 m_pool.emplace_back(buf.Move());
144 for (
auto& buf : m_pool) {
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1186
Data buffer.
Definition: Buffer.h:23
std::span< char > data()
Definition: Buffer.h:47
std::span< const char > data() const
Definition: Buffer.h:46
Buffer()
Definition: Buffer.h:25
Buffer(std::string_view str)
Definition: Buffer.h:33
void Deallocate()
Definition: Buffer.h:72
Buffer(const uv_buf_t &oth)
Definition: Buffer.h:29
Buffer Dup() const
Definition: Buffer.h:66
Buffer(const char *base_, size_t len_)
Definition: Buffer.h:41
static Buffer Allocate(size_t size)
Definition: Buffer.h:52
Buffer(std::span< const uint8_t > arr)
Definition: Buffer.h:35
static Buffer Dup(std::string_view in)
Definition: Buffer.h:54
static Buffer Dup(std::span< const uint8_t > in)
Definition: Buffer.h:60
Buffer Move()
Definition: Buffer.h:78
Buffer(char *base_, size_t len_)
Definition: Buffer.h:37
friend void swap(Buffer &a, Buffer &b)
Definition: Buffer.h:85
A simple pool allocator for Buffers.
Definition: Buffer.h:99
Buffer operator()()
Allocate a buffer.
Definition: Buffer.h:127
SimpleBufferPool(size_t size=4096)
Constructor.
Definition: Buffer.h:105
SimpleBufferPool & operator=(const SimpleBufferPool &other)=delete
size_t Remaining() const
Get number of buffers left in the pool before a new buffer will be allocated from the heap.
Definition: Buffer.h:154
void Release(std::span< Buffer > bufs)
Release allocated buffers back into the pool.
Definition: Buffer.h:134
void Clear()
Clear the pool, releasing all buffers.
Definition: Buffer.h:143
SimpleBufferPool(const SimpleBufferPool &other)=delete
Buffer Allocate()
Allocate a buffer.
Definition: Buffer.h:114
~SimpleBufferPool()
Definition: Buffer.h:106
basic_string_view< char > string_view
Definition: core.h:520
EIGEN_CONSTEXPR Index size(const T &x)
Definition: Meta.h:479
void swap(wpi::SmallVectorImpl< T > &LHS, wpi::SmallVectorImpl< T > &RHS)
Implement std::swap in terms of SmallVector swap.
Definition: SmallVector.h:1299
Definition: ParallelTcpConnector.h:22
Definition: format.h:1544
It should be possible to cast uv_buf_t[] to WSABUF[] see http://msdn.microsoft.com/en-us/library/ms74...
Definition: win.h:234
char * base
Definition: win.h:236
ULONG len
Definition: win.h:235