ページの改善
いますぐフォークしてオンライン編集し、このページのプルリクエストを送信します。
Github へのログインが必要です。 これは小さな変更に適しています。
大きな変更を加えたい場合は、通常の cloneの使用をお勧めします。
日本語版について
個人的な学習のために、dlang.orgを翻訳したサイトです。
翻訳に際して、様々なサイトを参考にしています。
core.sync.barrier
The barrier module provides a primitive for synchronizing the progress of
a group of threads.
License:
Authors:
Sean Kelly
Source core/sync/barrier.d
- class
Barrier
; - 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 = new Barrier( 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(uint
limit
); - Initializes a barrier object which releases threads in groups of limit in size.Parameters:
uint limit
The number of waiting threads to release in unison. Throws:SyncError on error. - void
wait
(); - Wait for the pre-determined number of threads and then proceed.Throws:SyncError on error.
Copyright © 1999-2022 by the D Language Foundation | Page generated by
Ddoc on Wed Nov 23 08:32:10 2022