Movatterモバイル変換


[0]ホーム

URL:


D Logo
Menu
Search

Library Reference

version 2.112.0

overview

Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.Requires a signed-in GitHub account. This works well for small changes.If you'd like to make larger changes you may want to consider usinga local clone.

core.sync.barrier

The barrier module provides a primitive for synchronizing the progress of a group of threads.
License:
Boost License 1.0
Authors:
Sean Kelly

Sourcecore/sync/barrier.d

classBarrier;
This class represents a barrier across which threads may only travel in groups of a specific size.
Examples:
import core.thread;int  numThreads = 10;auto barrier    =newBarrier( numThreads );auto synInfo    =new Object;int  numReady   = 0;int  numPassed  = 0;void threadFn(){synchronized( synInfo )    {        ++numReady;    }    barrier.wait();synchronized( synInfo )    {        ++numPassed;    }}auto group =new ThreadGroup;for (int i = 0; i < numThreads; ++i ){    group.create( &threadFn );}group.joinAll();assert( numReady == numThreads && numPassed == numThreads );
this(uintlimit);
Initializes a barrier object which releases threads in groups of limit in size.
Parameters:
uintlimitThe number of waiting threads to release in unison.
Throws:
SyncError on error.
voidwait();
Wait for the pre-determined number of threads and then proceed.
Throws:
SyncError on error.
Copyright © 1999-2026 by theD Language Foundation | Page generated byDdoc on Sat Feb 21 00:05:34 2026

[8]ページ先頭

©2009-2026 Movatter.jp