From ad541c67761b8aa6da1566802c347cac4018d0c2 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Mon, 2 Nov 2026 20:50:24 +0100 Subject: Move the build sources into src/ --- src/ot_worker.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/ot_worker.h (limited to 'src/ot_worker.h') diff --git a/src/ot_worker.h b/src/ot_worker.h new file mode 100644 index 0000000..4954773 --- /dev/null +++ b/src/ot_worker.h @@ -0,0 +1,37 @@ +/* This software was written by Dirk Engling + It is considered beerware. Prost. Skol. Cheers or whatever. */ + +#ifndef OT_WORKER_H__ +#define OT_WORKER_H__ + +#include +#include +#include + +#include "trackerlogic.h" + +struct ot_worker; + +/* What a worker does between being started and being told to stop. It reads + worker->sock and works out of worker->ws; everything around it, from the + buffers to the counters to saying goodbye, is handled here. */ +typedef void (*ot_worker_run)(struct ot_worker *worker); + +/* A thread that serves requests on a socket of its own, with the buffers and + counters it needs. Each is allocated on its own, so taking on another one + never moves the record a running worker holds. */ +struct ot_worker { + pthread_t thread; + _Atomic int left; + int64_t sock; + ot_worker_run run; + struct ot_workstruct ws; +}; + +/* Start one. Returns -1 if it could not be started. */ +int worker_start(ot_worker_run run, int64_t sock); + +/* Wake every worker until it has left, then join it */ +void worker_stop_all(void); + +#endif -- cgit v1.3