]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Support condition variables.
authorRobert Haas <rhaas@postgresql.org>
Tue, 22 Nov 2016 19:26:40 +0000 (14:26 -0500)
committerRobert Haas <rhaas@postgresql.org>
Tue, 22 Nov 2016 19:27:11 +0000 (14:27 -0500)
commite8ac886c24776295dd9b025386a821061da8e4d1
treecdb4306afce149e7f9c8c0708d18ddee7737fc29
parent1c7861e81b4220364bef75d2445e9c0619f3f3f8
Support condition variables.

Condition variables provide a flexible way to sleep until a
cooperating process causes an arbitrary condition to become true.  In
simple cases, this can be accomplished with a WaitLatch/ResetLatch
loop; the cooperating process can call SetLatch after performing work
that might cause the condition to be satisfied, and the waiting
process can recheck the condition each time.  However, if the process
performing the work doesn't have an easy way to identify which
processes might be waiting, this doesn't work, because it can't
identify which latches to set.  Condition variables solve that problem
by internally maintaining a list of waiters; a process that may have
caused some waiter's condition to be satisfied must "signal" or
"broadcast" on the condition variable.

Robert Haas and Thomas Munro
12 files changed:
src/backend/access/transam/xact.c
src/backend/bootstrap/bootstrap.c
src/backend/postmaster/bgwriter.c
src/backend/postmaster/checkpointer.c
src/backend/postmaster/walwriter.c
src/backend/replication/walsender.c
src/backend/storage/lmgr/Makefile
src/backend/storage/lmgr/condition_variable.c [new file with mode: 0644]
src/backend/storage/lmgr/proc.c
src/include/storage/condition_variable.h [new file with mode: 0644]
src/include/storage/proc.h
src/include/storage/proclist.h