httpd/pool
src/httpd/pool.tur
bounded worker pool used by httpd/server.
Since: H7
defn
pool-new
(pool-new [size : int handler ptr<void>] :)
allocate a bounded worker pool and spawn `size` threads.
Parameters
| size | desired number of worker threads (clamped to >= 1). | |
| handler | :ptr<void> request handler; same contract as | |
| server-start's handler argument (forwarded verbatim | ||
| to srv-worker-loop on every dequeued connection). |
Returns
:ptr<void> -- opaque pool handle, or NULL if allocation or any thread creation failed before at least one worker was running.
Example
(def pool (pool-new 8 my-handler))
Since: H7
defn
pool-enqueue
(pool-enqueue [pool ptr<void> client-fd : int] :)
hand a client fd off to the pool's worker queue.
Parameters
| pool | :ptr<void> pool handle (NULL closes the fd and returns). | |
| client-fd | :int connected socket; ownership transferred to the pool. |
Example
(pool-enqueue pool client-fd)
Since: H7
defn
pool-stop
(pool-stop [pool ptr<void>] :)
signal shutdown, let workers drain queued connections,
Parameters
| pool | :ptr<void> pool handle (NULL is a no-op). |
Example
(pool-stop pool)
Since: H7
Internal definitions
pool-worker-loop