OpenSwoole\Atomic\Long->add

25.x is outdated, please check the latest version 26.x


Latest version: pecl install openswoole-26.2.0

Declaration

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

Parameters

value

The adding value to the atomic counter.

Return

Description

Add a value to the a 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 February 28, 2026