Swoole\Atomic::__construct

Declaration

<?php
Swoole\Atomic::__construct ( int $value = 0 )

Parameters

value

The init value of the atomic counter.

Return

Description

Create an Atomic counter.

Example

<?php
$counter = new Swoole\Atomic(123);
echo $counter->add(12)."\n";
echo $counter->sub(11)."\n";
echo $counter->cmpset(122, 999)."\n";
echo $counter->cmpset(124, 999)."\n";
echo $counter->get()."\n";