]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: thread: define cshared type
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 25 Apr 2025 09:37:07 +0000 (11:37 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 29 Apr 2025 13:10:06 +0000 (15:10 +0200)
commit3891456d209febfb1eb2d1d398b5b40602616423
treea2d452708d8a585cb8b6e81144c9e07f03714f10
parent7bad88c35c7547d52ac170ed9f89f29cccd6c46c
MINOR: thread: define cshared type

Define a new type "struct cshared". This can be used as a tool to
manipulate a global counter with thread-safety ensured. Each thread
would declare its thread-local cshared type, which would point to a
global counter.

Each thread can then add/substract value to their owned thread-local
cshared instance via cshared_add(). If the difference exceed a
configured limit, either positively or negatively, the global counter is
updated and thread-local instance is reset to 0. Each thread can safely
read the global counter value using cshared_read().
include/haproxy/thread-t.h
include/haproxy/thread.h