KEEL 1.0.0
Minimal C11 HTTP client/server library built on epoll/kqueue/io_uring/poll
Loading...
Searching...
No Matches
Data Fields
KlDrain Struct Reference

Backpressure write buffer. More...

#include <drain.h>

Collaboration diagram for KlDrain:
Collaboration graph
[legend]

Data Fields

KlDrainWriteFn write_fn
 
void * write_ctx
 
KlDrainCb on_drain
 
void * drain_ctx
 
KlAllocatoralloc
 
char * buf
 
size_t buf_len
 
size_t buf_cap
 
size_t max_size
 
int error
 

Detailed Description

Backpressure write buffer.

Sits between a producer (SSE, compress stream, WebSocket, etc.) and a writer function. When the writer returns would-block (0), KlDrain buffers the remaining data. The caller composes KlDrain with KlWatcher / KlAsyncOp to resume on write-readiness — KlDrain itself has zero event loop dependency.

Caller-owned struct (stack-allocatable). NOT thread-safe.

Field Documentation

◆ write_fn

KlDrainWriteFn KlDrain::write_fn

Underlying writer

◆ write_ctx

void* KlDrain::write_ctx

Writer context

◆ on_drain

KlDrainCb KlDrain::on_drain

Optional: buffer-drained callback

◆ drain_ctx

void* KlDrain::drain_ctx

Callback context

◆ alloc

KlAllocator* KlDrain::alloc

For buffer allocation

◆ buf

char* KlDrain::buf

Pending data (lazy-allocated)

◆ buf_len

size_t KlDrain::buf_len

Bytes pending

◆ buf_cap

size_t KlDrain::buf_cap

Buffer capacity

◆ max_size

size_t KlDrain::max_size

0 = unlimited, else hard cap

◆ error

int KlDrain::error

Sticky error flag


The documentation for this struct was generated from the following file: