当前位置: 首页>>代码示例>>PHP>>正文


PHP swoole_timer_tick函数代码示例

本文整理汇总了PHP中swoole_timer_tick函数的典型用法代码示例。如果您正苦于以下问题:PHP swoole_timer_tick函数的具体用法?PHP swoole_timer_tick怎么用?PHP swoole_timer_tick使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了swoole_timer_tick函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public function run($worker)
 {
     swoole_timer_tick(1000, function ($timer_id) {
         static $index = 0;
         $index = $index + 1;
         $this->process->push("Hello");
         var_dump($index);
         if ($index == 10) {
             swoole_timer_clear($timer_id);
         }
     });
 }
开发者ID:jinchunguang,项目名称:swoole-doc,代码行数:12,代码来源:msg_queue.php

示例2: newAfterTimer

 static function newAfterTimer()
 {
     $id = swoole_timer_tick(rand(1000, 10000), 'timer');
     G::$afterTimers[$id] = true;
     self::$index++;
     self::log(__METHOD__ . ": #{$id}");
 }
开发者ID:swoole,项目名称:tests,代码行数:7,代码来源:timer.php

示例3: online

 private function online($who)
 {
     if (!isset($this->gens[$who])) {
         $this->gens[$who] = $this->messageGenerator($who);
         $this->sendUsers();
         $this->broadcast($who, $who . " is online.");
     }
     if ($this->timer == null) {
         $this->timer = swoole_timer_tick(3000, function () {
             try {
                 $users = $this->getAllUsers();
                 foreach ($users as $user) {
                     if (!isset($this->getMessage[$user]) && !isset($this->getUpdateUsers[$user])) {
                         if (!isset($this->maybeOffline[$user])) {
                             $this->maybeOffline[$user] = true;
                         } else {
                             $this->offline($user);
                         }
                     } else {
                         if (isset($this->maybeOffline[$user])) {
                             unset($this->maybeOffline[$user]);
                         }
                     }
                 }
             } catch (\Exception $e) {
             }
         });
     }
 }
开发者ID:iwillhappy1314,项目名称:laravel-admin,代码行数:29,代码来源:chat_server.php

示例4: onWorkerStart

 public function onWorkerStart($serv, $worker_id)
 {
     if ($worker_id == 0) {
         $this->test = new Test();
         $this->test->index = 1;
         swoole_timer_tick(1000, array($this, 'onTick'), "Hello");
     }
 }
开发者ID:jinchunguang,项目名称:swoole-doc,代码行数:8,代码来源:Timer.php

示例5: register_timer

 /**
  *  注册定时任务
  */
 protected static function register_timer()
 {
     swoole_timer_tick(60000, function ($interval) {
         Test::load_config();
     });
     swoole_timer_tick(1000, function ($interval) {
         Test::do_something($interval);
     });
 }
开发者ID:shijl,项目名称:swoole,代码行数:12,代码来源:test.php

示例6: registerTimer

 public static function registerTimer()
 {
     \swoole_timer_tick(60000, function ($id) {
         self::loadConfig();
         defined('PHPKIT_RUN_DEBUG') && syslog(LOG_INFO, 'reload config success');
     });
     \swoole_timer_tick(1000, function ($id) {
         self::loadTask($id);
     });
 }
开发者ID:mawenpei,项目名称:swoole-crontab,代码行数:10,代码来源:Handler.php

示例7: init

 /**
  * [init 启动定时器]
  * @return [type] [description]
  */
 public static function init()
 {
     if (!isset(self::$tickKey)) {
         self::$tickKey = swoole_timer_tick(1000 * self::LOOPTIME, function () {
             //循环数组,踢出超时情况
             self::loop();
         });
         \SysLog::info(__METHOD__ . " init timer tick key == " . self::$tickKey, __CLASS__);
     }
 }
开发者ID:JeeLiu,项目名称:tsf,代码行数:14,代码来源:Timer.php

示例8: callback_function

function callback_function(swoole_process $worker)
{
    global $config;
    swoole_timer_tick($config['time'], function () {
        $fp = stream_socket_client("tcp://127.0.0.1:9502", $code, $msg, 1);
        $http_request = "GET / HTTP/1.1\r\n\r\n";
        fwrite($fp, $http_request);
        fclose($fp);
    });
}
开发者ID:luokaka,项目名称:dyserver,代码行数:10,代码来源:Timer.php

示例9: addTimer

 public function addTimer()
 {
     swoole_timer_tick(10000, function ($timer_id, $params = null) {
         if ($this->is_tasking) {
             return;
         }
         $this->server->task();
         $this->is_tasking = true;
     });
 }
开发者ID:hackers365,项目名称:mitm_inline,代码行数:10,代码来源:server.php

示例10: my_process1

function my_process1($process)
{
    global $argv;
    var_dump($process);
    swoole_set_process_name("php {$argv[0]}: my_process1");
    swoole_timer_tick(2000, function ($id) {
        global $serv;
        $serv->sendMessage("hello", 1);
    });
}
开发者ID:rambochase,项目名称:swoole-src,代码行数:10,代码来源:server.php

示例11: init

 /**
  * [init 启动定时器]
  * @return [type] [description]
  */
 public static function init()
 {
     if (!self::$isOnTimer) {
         swoole_timer_tick(1000 * self::LOOPTIME, function ($timer_id) {
             //循环数组,踢出超时情况
             self::loop($timer_id);
             self::$isOnTimer = false;
         });
         self::$isOnTimer = true;
     }
 }
开发者ID:delphinBlue,项目名称:tsf,代码行数:15,代码来源:Timer.php

示例12: init

 public static function init()
 {
     if (self::$timer === null) {
         for ($i = 0; $i < self::SLOT_SIZE; $i++) {
             self::$eventSlots[$i] = array();
         }
         self::$timer = swoole_timer_tick(1000 * self::LOOP_TIME, function ($tid) {
             self::loop($tid);
         });
     }
 }
开发者ID:zhanglei,项目名称:swPromise,代码行数:11,代码来源:Timer.class.php

示例13: worker

 /**
  * @brief 子进程做事情
  */
 public function worker()
 {
     $scheduler = $this->_objAha->getScheduler();
     swoole_timer_tick(5000, function () use($scheduler) {
         for ($i = 0; $i < 50; $i++) {
             $coroutine = $this->dbTest();
             if ($coroutine instanceof \Generator) {
                 $scheduler->newTask($coroutine);
                 $scheduler->run();
             }
         }
     });
 }
开发者ID:vucms,项目名称:aha,代码行数:16,代码来源:Asyncworker.php

示例14: _initTimer

 protected function _initTimer()
 {
     $redoConf = $this->_objAha->getConfig()->get('aha', 'redo');
     $interval = $redoConf['interval'];
     $triggerInterval = $redoConf['trigger_interval'];
     //当前周期内 把上个周期内失败的进行重试
     swoole_timer_tick($interval, function () {
         $this->_redo();
     });
     //每个时钟周期检查是否有redo没有发完的消息包
     swoole_timer_tick($triggerInterval, function () {
         $this->_trigger();
     });
 }
开发者ID:eyehere,项目名称:aha,代码行数:14,代码来源:Redo.php

示例15: tick

 public function tick($worker)
 {
     $this->worker = $worker;
     swoole_timer_tick(500, function () {
         while (true) {
             $this->checkExit();
             $task = $this->getQueue();
             if (empty($task)) {
                 break;
             }
             $this->Run($task);
         }
     });
 }
开发者ID:noikiy,项目名称:swoole-crontab,代码行数:14,代码来源:WorkerBase.class.php


注:本文中的swoole_timer_tick函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。