|
DeterministicESPAsyncWebServer v6.27.1
Zero-allocation, bounded-execution async HTTP server for ESP32
|
Server worker identity - implementation. More...
#include "network_drivers/session/worker.h"#include <atomic>#include "freertos/FreeRTOS.h"#include "freertos/queue.h"#include "freertos/task.h"Go to the source code of this file.
Functions | |
| int | detws_worker_count (void) |
| Number of server worker tasks (DETWS_WORKER_COUNT). | |
| int | detws_worker_self (void) |
| Worker id [0, count) of the calling task; 0 by default / single-worker. | |
| void | detws_worker_set_self (int id) |
Bind the calling task/thread to worker id id (worker entry / tests). | |
| void | detws_workers_start (detws_worker_pump_fn pump) |
Spawn the worker task(s) and start them running pump. No-op on host. | |
| bool | detws_defer (int worker_id, detws_deferred_fn fn, void *arg) |
Run fn(arg) on worker worker_id. Returns false if the queue is full. | |
| void | detws_worker_wake (int worker_id) |
Wake worker worker_id so it services a freshly-queued event now. | |
| void | detws_worker_run_deferred (int worker_id) |
Drain and run worker worker_id's deferred callbacks (called by the worker). | |
| void | detws_workers_stop (void) |
| Signal the worker task(s) to exit and wait briefly for them. No-op on host. | |
| bool | detws_workers_running (void) |
| True while worker task(s) are running (always false on host). | |
Server worker identity - implementation.
The id lives in thread-local storage so each worker task resolves its own per-worker state with no lock and no shared lookup. The block is part of task creation (no heap after begin()); an unbound context reads the zero default.
Definition in file worker.cpp.
| int detws_worker_count | ( | void | ) |
Number of server worker tasks (DETWS_WORKER_COUNT).
Definition at line 23 of file worker.cpp.
References DETWS_WORKER_COUNT.
| int detws_worker_self | ( | void | ) |
Worker id [0, count) of the calling task; 0 by default / single-worker.
Definition at line 28 of file worker.cpp.
| void detws_worker_set_self | ( | int | id | ) |
Bind the calling task/thread to worker id id (worker entry / tests).
Definition at line 33 of file worker.cpp.
| void detws_workers_start | ( | detws_worker_pump_fn | pump | ) |
Spawn the worker task(s) and start them running pump. No-op on host.
Definition at line 112 of file worker.cpp.
References DETWS_DEFER_QUEUE_DEPTH, DETWS_WORKER_CORE, DETWS_WORKER_COUNT, DETWS_WORKER_TASK_PRIORITY, and DETWS_WORKER_TASK_STACK.
Referenced by DetWebServer::begin().
| bool detws_defer | ( | int | worker_id, |
| detws_deferred_fn | fn, | ||
| void * | arg | ||
| ) |
Run fn(arg) on worker worker_id. Returns false if the queue is full.
Definition at line 130 of file worker.cpp.
References DETWS_WORKER_COUNT, and detws_worker_wake().
Referenced by DetWebServer::defer().
| void detws_worker_wake | ( | int | worker_id | ) |
Wake worker worker_id so it services a freshly-queued event now.
Each worker blocks between service iterations (it no longer free-runs the poll), so a producer that posts to a worker's event/defer queue must nudge it. This is a FreeRTOS task notification (no allocation, task- and tcpip-thread safe); a nudge that lands between the worker's pump and its block is latched in the notification count, so the next block returns at once and no event is missed. No-op on host (no worker task; the pipeline runs inline). Safe to call with an out-of-range id or before the task exists.
Definition at line 143 of file worker.cpp.
References DETWS_WORKER_COUNT.
Referenced by detws_defer(), listener_enqueue(), and lowlevel_sent_cb().
| void detws_worker_run_deferred | ( | int | worker_id | ) |
Drain and run worker worker_id's deferred callbacks (called by the worker).
Definition at line 152 of file worker.cpp.
References DETWS_WORKER_COUNT.
Referenced by DetWebServer::service_once().
| void detws_workers_stop | ( | void | ) |
Signal the worker task(s) to exit and wait briefly for them. No-op on host.
Definition at line 162 of file worker.cpp.
Referenced by DetWebServer::stop().
| bool detws_workers_running | ( | void | ) |
True while worker task(s) are running (always false on host).
Definition at line 172 of file worker.cpp.
Referenced by DetWebServer::handle().