reject() public méthode

public reject ( $reason )
Exemple #1
0
 /**
  * {@inheritdoc}
  */
 public function reject($reason = null)
 {
     parent::reject($reason);
 }
Exemple #2
0
 /**
  * {@inheritdoc}
  */
 public function reject(\Throwable $reason)
 {
     parent::reject($reason);
 }
Exemple #3
0
function any($array)
{
    return toFuture($array)->then(function ($array) {
        $keys = array_keys($array);
        $n = count($array);
        if ($n === 0) {
            throw new RangeException('any(): $array must not be empty');
        }
        $reasons = array();
        $future = new Future();
        $onfulfilled = array($future, "resolve");
        $onrejected = function ($index) use($future, &$reasons, &$n, $keys) {
            return function ($reason) use($index, $future, &$reasons, &$n, $keys) {
                $reasons[$index] = $reason;
                if (--$n === 0) {
                    $array = array();
                    foreach ($keys as $key) {
                        $array[$key] = $reasons[$key];
                    }
                    $future->reject($array);
                }
            };
        };
        foreach ($array as $index => $element) {
            $f = toFuture($element);
            $f->then($onfulfilled, $onrejected($index));
        }
        return $future;
    });
}
Exemple #4
0
 function setRequestTimer($topic, $id, $request, $timeout)
 {
     if ($timeout > 0) {
         $self = $this;
         $topics = $this->getTopics($topic);
         $future = new Future();
         $timer = $this->timer->setTimeout(function () use($future) {
             $future->reject(new TimeoutException('timeout'));
         }, $timeout);
         $request->whenComplete(function () use($self, $timer) {
             $self->timer->clearTimeout($timer);
         })->fill($future);
         return $future->catchError(function ($e) use($self, $topics, $topic, $id) {
             if ($e instanceof TimeoutException) {
                 $checkoffline = function () use($self, &$checkoffline, $topics, $topic, $id) {
                     $t = $topics[$id];
                     $t->timer = $self->timer->setTimeout($checkoffline, $t->heartbeat);
                     if ($t->count < 0) {
                         $self->offline($topics, $topic, $id);
                     } else {
                         --$t->count;
                     }
                 };
                 $checkoffline();
             }
         });
     }
     return $request;
 }