Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7888b09

Browse files
committed
Add BarrierArriveAndDetachExceptLast().
Provide a way for one process to continue the remaining phases of a(previously) parallel computation alone. Later patches will use this toextend Parallel Hash Join.Author: Melanie Plageman <melanieplageman@gmail.com>Reviewed-by: Thomas Munro <thomas.munro@gmail.com>Discussion:https://postgr.es/m/CA%2BhUKG%2BA6ftXPz4oe92%2Bx8Er%2BxpGZqto70-Q_ERwRaSyA%3DafNg%40mail.gmail.com
1 parent13b58f8 commit7888b09

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

‎src/backend/storage/ipc/barrier.c‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,28 @@ BarrierArriveAndDetach(Barrier *barrier)
205205
returnBarrierDetachImpl(barrier, true);
206206
}
207207

208+
/*
209+
* Arrive at a barrier, and detach all but the last to arrive. Returns true if
210+
* the caller was the last to arrive, and is therefore still attached.
211+
*/
212+
bool
213+
BarrierArriveAndDetachExceptLast(Barrier*barrier)
214+
{
215+
SpinLockAcquire(&barrier->mutex);
216+
if (barrier->participants>1)
217+
{
218+
--barrier->participants;
219+
SpinLockRelease(&barrier->mutex);
220+
221+
return false;
222+
}
223+
Assert(barrier->participants==1);
224+
++barrier->phase;
225+
SpinLockRelease(&barrier->mutex);
226+
227+
return true;
228+
}
229+
208230
/*
209231
* Attach to a barrier. All waiting participants will now wait for this
210232
* participant to call BarrierArriveAndWait(), BarrierDetach() or

‎src/include/storage/barrier.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ typedef struct Barrier
3737
externvoidBarrierInit(Barrier*barrier,intnum_workers);
3838
externboolBarrierArriveAndWait(Barrier*barrier,uint32wait_event_info);
3939
externboolBarrierArriveAndDetach(Barrier*barrier);
40+
externboolBarrierArriveAndDetachExceptLast(Barrier*barrier);
4041
externintBarrierAttach(Barrier*barrier);
4142
externboolBarrierDetach(Barrier*barrier);
4243
externintBarrierPhase(Barrier*barrier);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp