Ver Fonte

Update Timer

Joanhey há 6 anos atrás
pai
commit
d068d33995
1 ficheiros alterados com 7 adições e 8 exclusões
  1. 7 8
      Lib/Timer.php

+ 7 - 8
Lib/Timer.php

@@ -50,14 +50,14 @@ class Timer
      * @param EventInterface $event
      * @return void
      */
-    public static function init($event = null)
+    public static function init(EventInterface $event = null)
     {
         if ($event) {
             self::$_event = $event;
-        } else {
-            if (\function_exists('pcntl_signal')) {
-                \pcntl_signal(SIGALRM, array('\Workerman\Lib\Timer', 'signalHandle'), false);
-            }
+            return;
+        }
+        if (\function_exists('pcntl_signal')) {
+            \pcntl_signal(\SIGALRM, array('\Workerman\Lib\Timer', 'signalHandle'), false);
         }
     }
 
@@ -91,7 +91,7 @@ class Timer
         }
 
         if ($args === null) {
-            $args = [];
+            $args = array();
         }
 
         if (self::$_event) {
@@ -108,8 +108,7 @@ class Timer
             \pcntl_alarm(1);
         }
 
-        $time_now = \time();
-        $run_time = $time_now + $time_interval;
+        $run_time = \time() + $time_interval;
         if (!isset(self::$_tasks[$run_time])) {
             self::$_tasks[$run_time] = array();
         }