PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
pg_pthread.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * Declarations for missing POSIX thread components.
4 *
5 * Currently this supplies an implementation of pthread_barrier_t for the
6 * benefit of macOS, which lacks it. These declarations are not in port.h,
7 * because that'd require <pthread.h> to be included by every translation
8 * unit.
9 *
10 *-------------------------------------------------------------------------
11 */
12
13#ifndef PG_PTHREAD_H
14#define PG_PTHREAD_H
15
16#include <pthread.h> /* IWYU pragma: export */
17
18#ifndef HAVE_PTHREAD_BARRIER_WAIT
19
20#ifndef PTHREAD_BARRIER_SERIAL_THREAD
21#define PTHREAD_BARRIER_SERIAL_THREAD (-1)
22#endif
23
24typedef struct pg_pthread_barrier
25{
26 bool sense; /* we only need a one bit phase */
27 int count; /* number of threads expected */
28 int arrived; /* number of threads that have arrived */
30 pthread_cond_t cond;
32
34 const void *attr,
35 int count);
38
39#endif
40
41#endif
struct pg_pthread_barrier pthread_barrier_t
int pthread_barrier_wait(pthread_barrier_t *barrier)
int pthread_barrier_init(pthread_barrier_t *barrier, const void *attr, int count)
int pthread_barrier_destroy(pthread_barrier_t *barrier)
static THREAD_BARRIER_T barrier
Definition: pgbench.c:480
pthread_cond_t cond
Definition: pg_pthread.h:30
pthread_mutex_t mutex
Definition: pg_pthread.h:29