Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_network_accept_pool.h File Reference

Accept pool for parallel connection acceptance (nginx-style) More...

#include "n_common.h"
#include "n_network.h"
#include "n_thread_pool.h"
#include <time.h>
+ Include dependency graph for n_network_accept_pool.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  NETW_ACCEPT_POOL
 Structure of a parallel accept pool. More...
 
struct  NETW_ACCEPT_POOL_STATS
 Statistics for the accept pool. More...
 

Macros

#define netw_accept_pool_atomic_read_state(pool)   __atomic_load_n(&(pool)->state, __ATOMIC_ACQUIRE)
 Lock-free atomic read of the accept pool state.
 
#define netw_accept_pool_atomic_write_state(pool, val)   __atomic_store_n(&(pool)->state, (val), __ATOMIC_RELEASE)
 Lock-free atomic write of the accept pool state.
 
#define NETW_ACCEPT_POOL_IDLE   0
 accept pool state: idle, not yet started
 
#define NETW_ACCEPT_POOL_RUNNING   1
 accept pool state: running and accepting connections
 
#define NETW_ACCEPT_POOL_STOPPED   3
 accept pool state: fully stopped
 
#define NETW_ACCEPT_POOL_STOPPING   2
 accept pool state: stop requested
 

Typedefs

typedef void(* netw_accept_callback_t) (NETWORK *accepted, void *user_data)
 callback type for accepted connections.
 

Functions

NETW_ACCEPT_POOLnetw_accept_pool_create (NETWORK *server, size_t nb_threads, int accept_timeout, netw_accept_callback_t callback, void *user_data)
 Create a new accept pool.
 
int netw_accept_pool_destroy (NETW_ACCEPT_POOL **pool)
 Destroy an accept pool.
 
int netw_accept_pool_get_stats (NETW_ACCEPT_POOL *pool, NETW_ACCEPT_POOL_STATS *stats)
 Get a snapshot of pool statistics (thread-safe copy)
 
int netw_accept_pool_start (NETW_ACCEPT_POOL *pool)
 Start the accept pool (launches accept threads)
 
int netw_accept_pool_stop (NETW_ACCEPT_POOL *pool)
 Request the accept pool to stop.
 
int netw_accept_pool_wait (NETW_ACCEPT_POOL *pool, int timeout_sec)
 Wait for all accept threads to finish after a stop request.
 

Detailed Description

Accept pool for parallel connection acceptance (nginx-style)

Author
Castagnier Mickael
Version
1.0
Date
11/03/2026

Definition in file n_network_accept_pool.h.