]> git.kaiwu.me - haproxy.git/commit
MEDIUM: twork: Introduce a new cross-thread/thread-group deferred work API
authorOlivier Houchard <ohouchard@haproxy.com>
Thu, 20 Aug 2026 16:34:45 +0000 (18:34 +0200)
committerOlivier Houchard <cognet@ci0.org>
Thu, 10 Sep 2026 16:33:30 +0000 (18:33 +0200)
commitd6389e6946e745627d286af6be179466399fe20d
treec570f06b178daf60edd2f45e869e967cbb58831f
parentbc9524eb84665463db972c54232f03f425eba049
MEDIUM: twork: Introduce a new cross-thread/thread-group deferred work API

Introduce twork, a way to execute code on another thread, or another
thread group. The main motivation for that was to be able to obtain
information about file descriptor belonging to other thread groups, when
running with per-thread-group file descriptor tables.
The functions are :
int twork_call_on(struct twork *tw, int tid,
                  union twork_arg (*fn)(union twork_arg),
                  union twork_arg arg,
                  void (*done)(union twork_arg arg, union twork_arg ret));
Runs function fn on thread tid, providing arg as an argument, and
calling done from the caller thread when the work is complete.
int twork_call_tgroup(struct twork *tw, uint tgid,
                      union twork_arg (*fn)(union twork_arg),
                      union twork_arg arg,
                      void (*done)(union twork_arg arg, union twork_arg ret));
Same thing, but running on thread group tgid instead.

"done" is optional, if there is no need to be notified that the work is
complete.
"tw" is optional, if none is provided, one will be allocated
dynamically. Note that you can only cancel a twork if you're using one
that you provided by yourself.

int twork_cancel(struct twork *tw);
Cancels the tw, assuming it is not already running. It will return 1 on
success, and 0 on failure, in which case the work will be completed, and
the "done" function will be called.
Makefile
doc/configuration.txt
include/haproxy/defaults.h
include/haproxy/global-t.h
include/haproxy/twork-t.h [new file with mode: 0644]
include/haproxy/twork.h [new file with mode: 0644]
src/twork.c [new file with mode: 0644]