OpenSwoole\Atomic\Long->set

Latest version: pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5

Declaration

<?php OpenSwoole\Atomic\Long->set ( int $value = 0 )

Parameters

value

Update the value of the atomic counter.

Return

Description

Update the value of an atomic counter.

Example

<?php
$counter = new OpenSwoole\Atomic\Long(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";
Last updated on September 1, 2022