KEEL 1.0.0
Minimal C11 HTTP client/server library built on epoll/kqueue/io_uring/poll
Loading...
Searching...
No Matches
Data Structures | Typedefs | Functions
async.h File Reference
#include <keel/event_ctx.h>
#include <stdint.h>
Include dependency graph for async.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  KlAsyncOp
 An in-flight async operation that suspends a connection. More...
 

Typedefs

typedef struct KlServer KlServer
 
typedef struct KlConn KlConn
 
typedef struct KlAsyncOp KlAsyncOp
 
typedef void(* KlAsyncFn) (KlAsyncOp *op, void *user_data)
 Callback for async operation lifecycle events.
 

Functions

int kl_async_suspend (KlServer *s, KlConn *conn, KlAsyncOp *op)
 Suspend a connection for an async operation.
 
void kl_async_complete (KlServer *s, KlAsyncOp *op)
 Complete an async operation and resume the connection.
 

Typedef Documentation

◆ KlServer

typedef struct KlServer KlServer

◆ KlConn

typedef struct KlConn KlConn

◆ KlAsyncOp

typedef struct KlAsyncOp KlAsyncOp

◆ KlAsyncFn

typedef void(* KlAsyncFn) (KlAsyncOp *op, void *user_data)

Callback for async operation lifecycle events.

Parameters
opThe async operation.
user_dataOpaque pointer from op->user_data.

Function Documentation

◆ kl_async_suspend()

int kl_async_suspend ( KlServer s,
KlConn conn,
KlAsyncOp op 
)

Suspend a connection for an async operation.

Sets conn->state to KL_CONN_SUSPENDED, removes the client FD from the event loop, and adds the op to the server's active ops list. The connection is exempt from idle timeouts while suspended.

Parameters
sServer instance.
connConnection to suspend.
opCaller-owned async op (must remain valid until completion).
Returns
0 on success, -1 on failure.

◆ kl_async_complete()

void kl_async_complete ( KlServer s,
KlAsyncOp op 
)

Complete an async operation and resume the connection.

Calls op->on_resume, re-registers the client FD in the event loop, and drives the connection state machine forward (try immediate send, transition to SENDING/READING/CLOSED as appropriate).

If on_resume triggers another suspension (e.g. handler yields again), the new suspension takes effect and this function is a no-op after the on_resume call.

Parameters
sServer instance.
opAsync op to complete (removed from active list).