Ejemplo n.º 1
0
 /**
  * Invokes the callback
  * @param  mixed ...$args Arguments
  * @return mixed
  */
 public function __invoke()
 {
     if ($this->timer !== null) {
         Timer::remove($this->timer);
         $this->timer = null;
     }
     if ($this->cb === null) {
         return null;
     }
     if ($this->context === null || Daemon::$context !== null) {
         try {
             return call_user_func_array($this->cb, func_get_args());
         } catch (\Exception $e) {
             Daemon::uncaughtExceptionHandler($e);
         }
         return;
     }
     $this->context->onWakeup();
     try {
         $result = call_user_func_array($this->cb, func_get_args());
         $this->context->onSleep();
         return $result;
     } catch (\Exception $e) {
         Daemon::uncaughtExceptionHandler($e);
         $this->context->onSleep();
     }
 }
Ejemplo n.º 2
0
 /**
  * Invokes the callback
  * @param  mixed ...$args Arguments
  * @return mixed
  */
 public function __invoke(...$args)
 {
     if ($this->timer !== null) {
         Timer::remove($this->timer);
         $this->timer = null;
     }
     if ($this->cb === null) {
         return null;
     }
     if ($this->context === null || Daemon::$context !== null) {
         try {
             $cb = $this->cb;
             return $cb(...$args);
         } catch (\Exception $e) {
             Daemon::uncaughtExceptionHandler($e);
         }
         return;
     }
     $this->context->onWakeup();
     try {
         $cb = $this->cb;
         $result = $cb(...$args);
         $this->context->onSleep();
         return $result;
     } catch (\Exception $e) {
         Daemon::uncaughtExceptionHandler($e);
         $this->context->onSleep();
     }
 }