mirror of
https://github.com/postgres/postgres.git
synced 2025-11-07 19:06:32 +03:00
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
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
#include "postmaster/autovacuum.h"
|
||||
#include "replication/slot.h"
|
||||
#include "replication/syncrep.h"
|
||||
#include "storage/condition_variable.h"
|
||||
#include "storage/standby.h"
|
||||
#include "storage/ipc.h"
|
||||
#include "storage/lmgr.h"
|
||||
@@ -802,6 +803,9 @@ ProcKill(int code, Datum arg)
|
||||
*/
|
||||
LWLockReleaseAll();
|
||||
|
||||
/* Cancel any pending condition variable sleep, too */
|
||||
ConditionVariableCancelSleep();
|
||||
|
||||
/* Make sure active replication slots are released */
|
||||
if (MyReplicationSlot != NULL)
|
||||
ReplicationSlotRelease();
|
||||
@@ -907,6 +911,9 @@ AuxiliaryProcKill(int code, Datum arg)
|
||||
/* Release any LW locks I am holding (see notes above) */
|
||||
LWLockReleaseAll();
|
||||
|
||||
/* Cancel any pending condition variable sleep, too */
|
||||
ConditionVariableCancelSleep();
|
||||
|
||||
/*
|
||||
* Reset MyLatch to the process local one. This is so that signal
|
||||
* handlers et al can continue using the latch after the shared latch
|
||||
|
||||
Reference in New Issue
Block a user