https://github.com/vtsykun/php-ext-counter
PHP atomic counter C extension
https://github.com/vtsykun/php-ext-counter
Last synced: about 1 month ago
JSON representation
PHP atomic counter C extension
- Host: GitHub
- URL: https://github.com/vtsykun/php-ext-counter
- Owner: vtsykun
- Created: 2019-06-03T14:38:21.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-06-03T15:28:54.000Z (almost 6 years ago)
- Last Synced: 2025-01-26T08:24:52.287Z (3 months ago)
- Language: C
- Size: 7.81 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PHP atomic counter extension
Simple SysV semaphore counter. It will be automatically undone
when the process terminates.## Supported platform
* Linux (kernel > 2.1) (not Solaris)## Install
```
phpize
./configure
make
make install
```Add `extension=counterlock.so` to your php.ini configuration
### Install on CentOS and RHEL
```
/opt/remi/php71/root/usr/bin/phpize
./configure --with-php-config=/opt/remi/php71/root/usr/bin/php-config
make
make install
echo "extension=counterlock.so" > /etc/opt/remi/php71/php.d/20-counerlock.ini
```## Run test
```
phpize
./configure
make
make test
```## Example Usage
```php
* The semaphore permissions. Actually this value is
* set only if the process finds it is the only process currently
* attached to the semaphore.
*
*
* @return resource a positive counter identifier on success, or FALSE on
* error.
*/
function counter_create ($key, $perm = 0666) {}/**
* Increment a counter
* @param resource $resource
* resource is a resource, obtained from counter_create.
*
* @return bool TRUE on success or FALSE on failure.
*/
function counter_increment ($resource) {}/**
* Increment a counter
* @param resource $resource
* A resource handle as returned by
* counter_create.
*
* @return bool TRUE on success or FALSE on failure.
*/
function counter_decrement ($resource) {}/**
* Get counter value.
*
* @param resource $resource
* A resource handle as returned by
* counter_create.
*
* @return integer|false FALSE on failure.
*/
function counter_value ($resource) {}/**
* Remove a System V semaphore for counter
* @param resource $resource
* A semaphore resource identifier as returned
* by sem_get.
*
* @return bool TRUE on success or FALSE on failure.
*/
function counter_remove ($resource) {}// End of counterlock.
```