guanhui07/timer

php定时器

v1.0.0 2023-02-17 00:45 UTC

This package is auto-updated.

Last update: 2024-09-17 04:19:13 UTC


README

php定时器,参考了workerman源码,实现一个单进程(守护进程)的定时器。

原理

  1. 利用pcntl,实现守护进程化
  2. 利用stream_select的超时机制来实现sleep,如果有event扩展的话,优先使用event扩展
  3. 定时器是通过时间堆的方式实现,利用php的spl的优先队列

安装

composer require guanhui07/timer

使用

./test/index.php