MEDIUM: threads: Adds a set of functions to handle sync-point
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 19 Oct 2017 09:59:15 +0000 (11:59 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 31 Oct 2017 12:58:29 +0000 (13:58 +0100)
commit339fff8a18046aada616ac41437451b1f180534f
tree2fe656d5ef6218137c11124b5105aedb61f717f3
parentbe0faa2e47939e2672266a1a23b8a6de542b520e
MEDIUM: threads: Adds a set of functions to handle sync-point

A sync-point is a protected area where you have the warranty that no concurrency
access is possible. It is implementated as a thread barrier to enter in the
sync-point and another one to exit from it. Inside the sync-point, all threads
that must do some syncrhonous processing will be called one after the other
while all other threads will wait. All threads will then exit from the
sync-point at the same time.

A sync-point will be evaluated only when necessary because it is a costly
operation. To limit the waiting time of each threads, we must have a mechanism
to wakeup all threads. This is done with a pipe shared by all threads. By
writting in this pipe, we will interrupt all threads blocked on a poller. The
pipe is then flushed before exiting from the sync-point.
include/common/hathreads.h
src/hathreads.c