承接 nyugodt/proc 相关项目开发

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

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

nyugodt/proc

Composer 安装命令:

composer require nyugodt/proc

包简介

An utility library for process related functionality for PHP.

README 文档

README

An utility library for process related functionality for PHP.

Dependencies

This library depends on the semaphore, shared memory and ipc functions of PHP for the use of the SemLock class, which are not available on Windows.

Usage

This library provides two classes, FileLock and SemLock. Both works in the same way. They can be instantiated by a ::newInstance() method, which accepts an optional parameter as a path. If a lock is created with the same path in different processes, only one of them will be able to execute code inside the synchronize() call. Once a process ends it's synchronize() call, it releases the lock and another process takes the execution.

If no path is provided, it gets the full path of the calling file.

<?php
$lock = \Nyugodt\Proc\FileLock::newInstance();
$lock->synchronize(function(){
  echo "This function will not be executed by two threads at the same time.\n";
  sleep(3);
  echo "Process ended!\n";
});

If this example code gets executed by multiple processes, every process will wait the current running process who grabbed the lock first until the sleep(3) call ends and exits the synchronize() call.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固