承接 geoffroy-aubry/mutex 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

geoffroy-aubry/mutex

最新稳定版本:v1.0.1

Composer 安装命令:

composer require geoffroy-aubry/mutex

包简介

Mutex & Semaphore PHP implementations both based only on flock() function.

README 文档

README

Latest stable version

Mutex & Semaphore PHP implementations both based only on flock() function.

Demo

Mutex

File: demo-mutex.php.

Example:

$oLogger = new MinimalLogger();
$oMutex = new Mutex($oLogger, 100, '/tmp/demo-lock');

$oMutex->acquire();
echo "Do anything for 3 seconds…\n";
sleep(3);
$oMutex->release();

⇒ RESULT for 2 processes P1 and P2:

P1 $ php examples/demo-mutex.php
Do anything for 3 seconds…

P2 $ php examples/demo-mutex.php
Waiting to acquire Mutex lock on /tmp/demo-lock…
Mutex lock acquired after 2.57s
Do anything for 3 seconds…

Semaphore

File: demo-semaphore.php.

Example, semaphore with 2 units of a resource /tmp/demo-sem:

$oLogger = new MinimalLogger();
$oSem = new Semaphore($oLogger, 2, 100, '/tmp/demo-sem');

$oSem->acquire();
echo "Do anything for 3 seconds…\n";
sleep(3);
$oSem->release();

⇒ RESULT for 3 processes P1, P2 and P3:

P1 $ php examples/demo-semaphore.php
Do anything for 3 seconds…

P2 $ php examples/demo-semaphore.php
Do anything for 3 seconds…

P3 $ php examples/demo-semaphore.php
Waiting to acquire lock on /tmp/demo-sem…
Lock acquired after 2.30s
Do anything for 3 seconds…

Usage

Mutex is available via Packagist.

  1. Class autoloading and dependencies are managed by Composer so install it following the instructions on Composer: Installation - *nix or just run the following command:
$ curl -sS https://getcomposer.org/installer | php
  1. Add dependency to GAubry\Mutex into require section of your composer.json:
    {
        "require": {
            "geoffroy-aubry/mutex": "1.*"
        }
    }

and run php composer.phar install from the terminal into the root folder of your project.

  1. Include Composer's autoloader and use the GAubry\Mutex classes.

Copyrights & licensing

Licensed under the GNU Lesser General Public License v3 (LGPL version 3). See LICENSE file for details.

Change log

See CHANGELOG file for details.

Git branching model

The git branching model used for development is the one described and assisted by twgit tool: https://github.com/Twenga/twgit.

统计信息

  • 总下载量: 155
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-3.0
  • 更新时间: 2015-09-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固