<?phpfunction newChild($func_name) { echo "enter newChild\n"; $args = func_get_args(); unset($args[0]); $pid = pcntl_fork(); if ($pid == 0) { function_exists($func_name) and exit(call_user_func_array($func_name, $args)) or exit(-1); } else if($pid == -1) { echo "Couldn't create child process"; } else { return $pid; }}function on_timer() { echo "timer called\n";}/** * @param $func string, function name * @param $timeouts int, microtimes for time delay */function timer($func, $timeouts){ echo "enter timer\n"; $base = event_base_new(); $event = event_new(); event_set($event, 0, EV_TIMEOUT, $func); event_base_set($event, $base); event_add($event, $timeouts); event_base_loop($base);}$pid = newChild("timer", "on_timer", 5000000);if ($pid > 0) { echo "master process exit\n";}
详细解决方案
PHP中运用pcntl和libevent实现Timer功能
热度:73 发布时间:2016-04-28 21:49:15.0
相关解决方案
- 吐了,java Timer 终止不了。
- timer.schedule 不能配备按月执行 哪位ggjj帮帮忙
- 吐了,java Timer 停止不了。解决办法
- Registering a Timer Alarm的有关问题
- Java Timer,该怎么处理
- java.util.Timer,该如何处理
- java Timer 定时器不依照时间运行
- java timer cancle,怎么继续原来的程序
- java Timer,该如何处理
- Timer 定时器解决思路
- C# Timer 录像时间,该如何解决
- Timer.Elapsed事件怎么传递参数
- ASP.NET中System.Timer.Timer类怎么使用
- 使用AJax技术的 aspx.CS 文件中,有一个 Timer 控件,怎么在Timer 的 Timer1_Tick 事件中 弹出一个 showModalDialog 模态窗口 ? 100 分奉上
- timer 还没有解决,该如何处理
- 关于System.Timers.Timer,该怎么处理
- Ajax Timer 怎么调用客户端函数
- jbpm 创建流程实例时 org.jbpm.scheduler.exe.Timer is not mapped.java.lang.IndexOutOfBoun,该怎么处理
- Timer 类找不到.....为什么?
- debian停安装php的一些扩展geoip,mongo,redis,libevent,proctitle,inotify,pcntl
- php5+php-frm+libevent+memcached为何这种环境能解析.php,该如何处理
- Timer 种
- 腾挪的执行者 - ENTER_FRAME & Timer
- spring 对 timer 的支持 兑现简单的web中定时器操作
- 一行读nodejs(二)-控制台和定时器(console &Timer)
- timer.schedule 不能配置按月执行 何位ggjj帮帮忙
- 异常信息:Exception in thread "Timer-0" java.lang.NoClassDefFoundError: org/ibex/nest
- 大家帮看看这是什么错误“Exception in thread "Timer-83" java.lang.NullPointerException”
- 关于java.util.Timer,该如何处理
- Cannot find class [org.springframework.scheduling.timer.ScheduledTimerTask] for解决方法