MEDIUM: threads: Add hathreads header file
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 12 Oct 2017 14:09:09 +0000 (16:09 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 31 Oct 2017 12:58:23 +0000 (13:58 +0100)
commit1a2b56ea8e33805996994e64aa74c348cf543116
tree6f7f178eca09beca9033af4c92cf0b6d4139a2ab
parent7122ab31b195edb511fecf9c20904701970b195f
MEDIUM: threads: Add hathreads header file

This file contains all functions and macros used to deal with concurrency in
HAProxy. It contains all high-level function to do atomic operation
(HA_ATOMIC_*). Note, for now, we rely on "__atomic" GCC builtins to do atomic
operation. So HAProxy can be compiled with the thread support iff these builtins
are available.

It also contains wrappers around plocks to use spin or read/write locks. These
wrappers are used to abstract the internal representation of the locking system
and to add information to help debugging, when compiled with suitable
options.

To add extra info on locks, you need to add DEBUG=-DDEBUG_THREAD or
DEBUG=-DDEBUG_FULL compilation option. In addition to timing info on locks, we
keep info on where a lock was acquired the last time (function name, file and
line). There are also the thread id and a flag to know if it is still locked or
not. This will be useful to debug deadlocks.
Makefile
include/common/hathreads.h [new file with mode: 0644]
src/hathreads.c [new file with mode: 0644]