Documentation

Barrier
in package
uses ForbidCloning, ForbidSerialization

FinalYes

A barrier is a synchronization primitive.

The barrier is initialized with a certain count, which can be increased and decreased until it reaches zero.

A count of one can be used to block multiple coroutines until a certain condition is met.

A count of N can be used to await multiple coroutines doing an action to complete.

Example

$barrier = new Amp\Sync\Barrier(2);
$barrier->arrive();
$barrier->arrive(); // Barrier::await() returns immediately now

$barrier->await();

Table of Contents

Properties

$completion  : DeferredFuture
$count  : int

Methods

__construct()  : mixed
__serialize()  : never
__unserialize()  : never
arrive()  : void
await()  : void
getCount()  : int
register()  : void
__clone()  : mixed

Properties

Methods

__construct()

public __construct(positive-int $count) : mixed
Parameters
$count : positive-int

__unserialize()

public final __unserialize(array<string|int, mixed> $data) : never
Parameters
$data : array<string|int, mixed>
Return values
never

arrive()

public arrive([positive-int $count = 1 ]) : void
Parameters
$count : positive-int = 1

getCount()

public getCount() : int
Return values
int

register()

public register([positive-int $count = 1 ]) : void
Parameters
$count : positive-int = 1

        
On this page

Search results