Swoole\Atomic->sub

4.x is outdated, please check the latest version 22.x


Latest version: pecl install openswoole-22.1.2

Declaration

<?php Swoole\Atomic->sub ( int $value = 0 )

Parameters

value

The subtraction value to the atomic counter.

Return

Description

Subtract a value to the a 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";
Last updated on August 31, 2022