14 ~DrainGuard() { this->owner.
draining_ =
false; }
20 size_t len = msg[0] | (msg[1] << 8);
25 if (
static_cast<size_t>(sent) <
len) {
49 if (this->
count_ >= API_MAX_SEND_QUEUE)
52 const size_t new_len = total_len - skip;
59 if (this->
buf_.
size() + new_bytes > this->buf_.capacity()) {
63 if (this->
head_ > 0) {
76 dst[1] = new_len >> 8;
78 for (
const struct iovec *
end = iov + iovcnt; iov !=
end; iov++) {
83 std::memcpy(dst,
static_cast<const uint8_t *
>(iov->
iov_base) + skip,
len);
void drop_front(size_t drop)
Drop the first drop bytes, sliding the rest down. Precondition: drop <= size().
void release()
Release all memory (equivalent to std::vector swap trick).
uint8_t * append(size_t n)
Grow by n bytes; returns the new bytes, or nullptr on allocation failure.
bool reserve(size_t n) ESPHOME_ALWAYS_INLINE
Returns false if allocation fails; the buffer is left unchanged.
TCP send backlog, only used when the socket send buffer is full.
bool enqueue_iov(const struct iovec *iov, int iovcnt, size_t total_len, size_t skip)
Queue iov data from byte offset skip as one message.
static constexpr size_t LEN_PREFIX
static constexpr size_t MAX_BYTES
static constexpr size_t reserve_for(size_t want)
ssize_t try_drain(socket::Socket *socket)
Drain queued messages to the socket.
static constexpr size_t MAX_LONE_BYTES
bool release_when_drained_