GoLang Swoole\Atomic::__construct

request it (115)
GoLang replacement for PHP's Swoole\Atomic::__construct [edit | history]



Do you know a GoLang replacement for PHP's Swoole\Atomic::__construct? Write it!

PHP Swoole\Atomic::__construct

PHP original manual for Swoole\Atomic::__construct [ show | php.net ]

Swoole\Atomic::__construct

(PHP 5 >= 5.2.0, PHP 7, PECL swoole >= 1.9.0)

Swoole\Atomic::__constructConstruct a swoole atomic object.

Description

public Swoole\Atomic::__construct ([ integer $value ] )

Swoole atomic object is a integer variable allows any processor to atomically test and modify. It is implemented based on CPU atomic instructions. The Swoole atomic variables have to defined before swoole_server->start.

Compare-and-swap (CAS) is an atomic instruction used in multithreading to achieve synchronization. It compares the content of a memory location with a given value and, only if they are the same, modifies the content of that memory location to a new given value.

Parameters

value

The value of the atomic object.