]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: tasks: Introduce __task_get_current_owner
authorOlivier Houchard <ohouchard@haproxy.com>
Tue, 28 Apr 2026 16:09:19 +0000 (18:09 +0200)
committerOlivier Houchard <cognet@ci0.org>
Fri, 12 Jun 2026 09:49:09 +0000 (11:49 +0200)
Introduce a new function, __task_get_current_owner, that returns the
owner of a task based on its current tid.
-1 means there is no current owner, otherwise either the tid is >= 0, in
which case it will just return it, or it's < -1, in which case it will
return -2 - tid, the tid of the thread with the current ownership.

include/haproxy/task.h

index df4b42ea5ba65bfe5340512d38d015b4323b9fc8..8608f6fdae1f8dd51845959dc1176f080eb1053d 100644 (file)
@@ -269,6 +269,13 @@ static inline int __task_get_new_tid_field(int curtid)
        return -2 - tid;
 }
 
+static inline int __task_get_current_owner(int curtid)
+{
+       if (curtid >= 0 || curtid == -1)
+               return curtid;
+       return ~(curtid + 1);
+}
+
 /* puts the task <t> in run queue with reason flags <f>, and returns <t> */
 /* This will put the task in the local runqueue if the task is only runnable
  * by the current thread, in the global runqueue otherwies. With DEBUG_TASK,