PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
barrier.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * barrier.h
4 * Barriers for synchronizing cooperating processes.
5 *
6 * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
8 *
9 * src/include/storage/barrier.h
10 *
11 *-------------------------------------------------------------------------
12 */
13#ifndef BARRIER_H
14#define BARRIER_H
15
16/*
17 * For the header previously known as "barrier.h", please include
18 * "port/atomics.h", which deals with atomics, compiler barriers and memory
19 * barriers.
20 */
21
23#include "storage/spin.h"
24
25typedef struct Barrier
26{
27 slock_t mutex;
28 int phase; /* phase counter */
29 int participants; /* the number of participants attached */
30 int arrived; /* the number of participants that have
31 * arrived */
32 int elected; /* highest phase elected */
33 bool static_party; /* used only for assertions */
36
37extern void BarrierInit(Barrier *barrier, int participants);
38extern bool BarrierArriveAndWait(Barrier *barrier, uint32 wait_event_info);
41extern int BarrierAttach(Barrier *barrier);
42extern bool BarrierDetach(Barrier *barrier);
43extern int BarrierPhase(Barrier *barrier);
45
46#endif /* BARRIER_H */
bool BarrierArriveAndDetachExceptLast(Barrier *barrier)
Definition: barrier.c:213
int BarrierParticipants(Barrier *barrier)
Definition: barrier.c:281
bool BarrierArriveAndDetach(Barrier *barrier)
Definition: barrier.c:203
int BarrierAttach(Barrier *barrier)
Definition: barrier.c:236
void BarrierInit(Barrier *barrier, int participants)
Definition: barrier.c:100
int BarrierPhase(Barrier *barrier)
Definition: barrier.c:265
bool BarrierArriveAndWait(Barrier *barrier, uint32 wait_event_info)
Definition: barrier.c:125
struct Barrier Barrier
bool BarrierDetach(Barrier *barrier)
Definition: barrier.c:256
uint32_t uint32
Definition: c.h:485
static THREAD_BARRIER_T barrier
Definition: pgbench.c:480
bool static_party
Definition: barrier.h:33
int participants
Definition: barrier.h:29
int elected
Definition: barrier.h:32
ConditionVariable condition_variable
Definition: barrier.h:34
int arrived
Definition: barrier.h:30
slock_t mutex
Definition: barrier.h:27
int phase
Definition: barrier.h:28