Core server - server worker identity. More...
Go to the source code of this file.
Classes | |
| struct | WorkerDeferArgs |
| One deferred call: what runs, and what it is given. More... | |
| struct | WorkersVars |
| struct | WorkerNs |
| The entries. More... | |
Macros | |
| #define | PROTOCORE_OWNERS(owner_) |
| The owners of the library, as the list that MMGR_OWNERS takes. | |
Typedefs | |
| typedef void(* | protocore_worker_pump_fn) (int worker_id) |
| Pump callback run by each worker task with its worker id. | |
| typedef void(* | protocore_deferred_fn) (void *arg) |
| Deferred callback signature. | |
Functions | |
| EMBED_BEGIN_DECLS int | protocore_worker_count (void) |
| Number of server worker tasks (PROTOCORE_WORKER_COUNT). | |
| int | protocore_worker_self (void) |
| Worker id [0, count) of the calling task; 0 by default / single-worker. | |
| void | protocore_worker_set_self (int id) |
Bind the calling task/thread to worker id id (worker entry / tests). | |
| void | protocore_cellblocks_bind (int worker, const MinimumSecurityGuard *plain, const MaxSecurityGuard *secure) |
Hand worker slot worker the guards it borrows through. | |
| const MinimumSecurityGuard * | protocore_plain_guard (void) |
| The plaintext guard the calling worker borrows through. Never NULL. | |
| const MaxSecurityGuard * | protocore_secure_guard (void) |
| The key-material guard the calling worker borrows through. Never NULL. | |
| const CellOwner * | protocore_plain_owner (void) |
| The owner that every plaintext take in the library names. Never NULL. | |
| const CellOwner * | protocore_secure_owner (void) |
| The owner that every key-material take in the library names. Never NULL. | |
| void * | protocore_plain_persist (size_t n) |
n persistent plaintext bytes, zeroed, or NULL if the calling worker's cellblock is full. | |
| void * | protocore_secure_persist (size_t n) |
n persistent key-material bytes, zeroed, or NULL if the calling worker's cellblock is full. | |
| void | protocore_workers_run_deferred (uint8_t *work) |
| void | protocore_workers_running (uint8_t *work) |
| void | protocore_workers_start (uint8_t *work) |
| void | protocore_workers_stop (uint8_t *work) |
| void | protocore_workers_wake (uint8_t *work) |
| void | protocore_workers_defer (uint8_t *work) |
| uint8_t * | protocore_worker_span (void) |
| The PROTOCORE_WORKER_BORROW bytes this module's state lives in. | |
Variables | |
| WorkersVars | WorkersV |
| The operands and the outcome. | |
Core server - server worker identity.
The server pipeline runs in one or more dedicated worker tasks (see PROTOCORE_WORKER_COUNT). Each worker owns a disjoint partition of connection slots (slot i -> worker i % count) and its own scratch arena, so per-worker state (the arena, work buffers) is selected by the caller's worker id. This header is the single source of that id.
The id is per-task/per-thread: a worker binds itself once at task entry via protocore_worker_set_self(); any context that has not bound an id (the user's loop(), a unit test, the network stack's own thread) reads 0, which is also the only valid id in the default single-worker build, so PROTOCORE_WORKER_COUNT == 1 is byte-for-byte the original single-pipeline behavior.
Definition in file worker.h.
| #define PROTOCORE_OWNERS | ( | owner_ | ) |
The owners of the library, as the list that MMGR_OWNERS takes.
worker.c expands MMGR_OWNERS over this list one time for the program. Each entry is an identity and the name that a reader prints.
| typedef void(* protocore_worker_pump_fn) (int worker_id) |
| typedef void(* protocore_deferred_fn) (void *arg) |
| EMBED_BEGIN_DECLS int protocore_worker_count | ( | void | ) |
Number of server worker tasks (PROTOCORE_WORKER_COUNT).
| int protocore_worker_self | ( | void | ) |
Worker id [0, count) of the calling task; 0 by default / single-worker.
With PROTOCORE_WORKER_COUNT == 1 (the default) there is exactly one worker, so the answer is 0 by construction and this is an inline constant - no lookup, no call. Every borrow asks, so the multi-worker lookup is paid only where there is more than one worker to tell apart.
| void protocore_worker_set_self | ( | int | id | ) |
Bind the calling task/thread to worker id id (worker entry / tests).
| void protocore_cellblocks_bind | ( | int | worker, |
| const MinimumSecurityGuard * | plain, | ||
| const MaxSecurityGuard * | secure ) |
Hand worker slot worker the guards it borrows through.
| worker | a worker id in [0, PROTOCORE_WORKER_COUNT); anything else is ignored. |
| plain | the minimum-security guard for plaintext, or NULL to leave the slot on the ghost's. |
| secure | the maximum-security guard for key material, or NULL to leave it on the ghost's. |
| const MinimumSecurityGuard * protocore_plain_guard | ( | void | ) |
The plaintext guard the calling worker borrows through. Never NULL.
| const MaxSecurityGuard * protocore_secure_guard | ( | void | ) |
The key-material guard the calling worker borrows through. Never NULL.
| const CellOwner * protocore_plain_owner | ( | void | ) |
The owner that every plaintext take in the library names. Never NULL.
References protocore_plain_owner().
Referenced by protocore_plain_owner().
| const CellOwner * protocore_secure_owner | ( | void | ) |
The owner that every key-material take in the library names. Never NULL.
References protocore_secure_owner().
Referenced by protocore_secure_owner().
| void * protocore_plain_persist | ( | size_t | n | ) |
n persistent plaintext bytes, zeroed, or NULL if the calling worker's cellblock is full.
State that lasts across dispatches starts from zero, and a cellblock hands its cells back as they were, so this is the persistent borrow followed by the zeroing.
References protocore_plain_persist().
Referenced by protocore_plain_persist().
| void * protocore_secure_persist | ( | size_t | n | ) |
n persistent key-material bytes, zeroed, or NULL if the calling worker's cellblock is full.
References protocore_secure_persist().
Referenced by protocore_secure_persist().
| void protocore_workers_run_deferred | ( | uint8_t * | work | ) |
Referenced by protocore_workers_defer().
| void protocore_workers_running | ( | uint8_t * | work | ) |
Referenced by protocore_workers_defer().
| void protocore_workers_start | ( | uint8_t * | work | ) |
Referenced by protocore_workers_defer().
| void protocore_workers_stop | ( | uint8_t * | work | ) |
Referenced by protocore_workers_defer().
| void protocore_workers_wake | ( | uint8_t * | work | ) |
Referenced by protocore_workers_defer().
| void protocore_workers_defer | ( | uint8_t * | work | ) |
| uint8_t * protocore_worker_span | ( | void | ) |
The PROTOCORE_WORKER_BORROW bytes this module's state lives in.
Stated beside the namespace rather than on it: an entry takes a borrow, and this is where that borrow comes from. Taken once from the end of the pool, which no mark and no release walks, so the state lasts the life of the program.
|
extern |
The operands and the outcome.