Skip to content

Commit

Permalink
document class \Swoole\Thread\Barrier
Browse files Browse the repository at this point in the history
Signed-off-by: Demin Yin <[email protected]>
  • Loading branch information
deminy committed Jan 5, 2025
1 parent e72a7bc commit b25c950
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/swoole/Swoole/Thread/Barrier.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
namespace Swoole\Thread;

/**
* Class \Swoole\Thread\Barrier.
* A synchronization mechanism that allows multiple threads to wait at a barrier point until the specified number of
* threads has reached the barrier.
*
* Once the required number of threads has arrived, all threads are released simultaneously.
*
* This class is available only when PHP is compiled with Zend Thread Safety (ZTS) enabled and Swoole is installed with
* the "--enable-swoole-thread" configuration option.
Expand All @@ -14,10 +17,22 @@
*/
final class Barrier
{
/**
* Initializes a new barrier with a specified thread count.
*
* @param int $count The number of threads required to meet at the barrier before they can proceed.
* This value must be greater than 0.
*/
public function __construct(int $count)
{
}

/**
* Blocks the current thread until the specified number of threads (provided in the constructor)
* have invoked this method.
*
* Once all threads have called this method, the barrier is lifted, and all waiting threads proceed.
*/
public function wait(): void
{
}
Expand Down

0 comments on commit b25c950

Please sign in to comment.