PHP - Manual: pht\AtomicInteger::inc
2024-12-26
(PECL pht >= 0.0.1)
pht\AtomicInteger::inc — Increments the atomic integer's value by one
This method will increment the atomic integer's value by one. Internally, the mutex lock of the atomic integer will be acquired, and so there is no need to manually acquire it (unless this operation needs to be grouped with other operations on the same atomic integer - see the example in pht\AtomicInteger::lock() for a demonstration of this).
此函数没有参数。
No return value.
Example #1 Incrementing an atomic integer's value
<?php
use pht\AtomicInteger;
$atomicInteger = new AtomicInteger();
$atomicInteger->inc();
$atomicInteger->inc();
var_dump($atomicInteger->get());
以上例程会输出:
int(2)
官方地址:https://www.php.net/manual/en/pht-atomicinteger.inc.php