Create RequestRecord.

@param string $pid
@param callable|null $success
@param callable|null $failure
@param callable|null $cancel
@param float $timeout
@return RequestRecord
171007
protected function createRequest($pid, callable $success = null, callable $failure = null, callable $cancel = null, $timeout = 0.0)
    {
        if ($timeout > 0.0)
        {
            $timeout = $timeout * 1000 + TimeSupport::now();
        }

        return new RequestRecord($pid, $success, $failure, $cancel, $timeout);
    }
362691
public function jsonToInterface( $data, $pid = null, $mapProvider = true )
    {
        $parser = new \PHPFHIRGenerated\PHPFHIRResponseParser();
        $fhirPatient = $parser->parse( $data );
        if ( $fhirPatient instanceof FHIRPatient ) {
            if ( $pid ) {
                $identifier = new FHIRIdentifier();
                $use = new FHIRIdentifierUse();
                $use->setValue("usual");
                $identifier->setUse($use);
                $value = new FHIRString();
                $value->setValue( $pid );
                $identifier->setValue($value);
                $fhirPatient->addIdentifier($identifier);
            }
            $interface = $this->modelToInterface( $fhirPatient, $mapProvider );

            return $interface;
        } else {
            // Error, the Resource does not match, expecting a Patient,
            // // but got something else.
            abort(403, 'Error, the Resource does not match, expecting a Patient, but got "' . typeOf($fhirPatient). '"');
        }

    }
649754
public static function killAndWait(
        int $pid,
        &$error = null,
        $name = 'process',
        bool $force = false,
        int $waitTime = 10
    ): bool {
        // do stop
        if (!self::kill($pid, $force)) {
            $error = "Send stop signal to the $name(PID:$pid) failed!";

            return false;
        }

        // not wait, only send signal
        if ($waitTime <= 0) {
            $error = "The $name process stopped";

            return true;
        }

        $startTime = \time();
        echo 'Stopping .';

        // wait exit
        while (true) {
            if (!self::isRunning($pid)) {
                break;
            }

            if (\time() - $startTime > $waitTime) {
                $error = "Stop the $name(PID:$pid) failed(timeout)!";
                break;
            }

            echo '.';
            sleep(1);
        }

        if ($error) {
            return false;
        }

        return true;
    }
1343306
public function get_session_lock($rowid, $timeout) {
        parent::get_session_lock($rowid, $timeout);

        $fullname = $this->dbname.'-'.$this->prefix.'-session-'.$rowid;
        $sql = 'SELECT MOODLELIB.GET_LOCK(:lockname, :locktimeout) FROM DUAL';
        $params = array('lockname' => $fullname , 'locktimeout' => $timeout);
        $this->query_start($sql, $params, SQL_QUERY_AUX);
        $stmt = $this->parse_query($sql);
        $this->bind_params($stmt, $params);
        $result = oci_execute($stmt, $this->commit_status);
        if ($result === false) { // Any failure in get_lock() raises error, causing return of bool false
            throw new dml_sessionwait_exception();
        }
        $this->query_end($result, $stmt);
        oci_free_statement($stmt);
    }
1210765
protected TimeoutId requestTimeout(final long delay, final TimeUnit unit, @Nullable final Object data) {
        return requestTimeout(delay, unit, null, data);
    }
1253657
public function subscribe($name, $id = null, $callback = null, $timeout = null, $failswitch = false) {
        $self = $this;
        if (!is_string($name)) {
            throw new TypeError('topic name must be a string');
        }
        if (is_callable($id) && !is_callable($callback)) {
            $timeout = $callback;
            $callback = $id;
            $id = null;
        }
        if (!is_callable($callback)) {
            throw new TypeError('callback must be a function.');
        }
        if (!isset($this->topics[$name])) {
            $this->topics[$name] = array();
        }
        if ($id === null) {
            if ($this->id == null) {
                $this->id = $this->autoId();
            }
            $this->id->then(function($id) use ($self, $name, $callback, $timeout, $failswitch) {
                $self->;
            });
            return;
        }
        // Default subscribe timeout is 5 minutes.
        if (!is_int($timeout)) $timeout = 300000;
        $topic = $this->getTopic($name, $id);
        if ($topic === null) {
            $topic = new stdClass();
            $settings = new InvokeSettings(array(
                'idempotent' => true,
                'failswitch' => $failswitch,
                'timeout' => $timeout
            ));
            $cb = function() use ($self, &$cb, $topic, $name, $id, $settings) {
                $args = array($id);
                $self->invoke($name, $args, $settings)
                     ->then($topic->handler, $cb);
            };
            $topic->handler = function($result) use ($self, $name, $id, $cb) {
                $topic = $self->getTopic($name, $id);
                if ($topic !== null) {
                    if ($result !== null) {
                        $callbacks = $topic->callbacks;
                        foreach ($callbacks as $callback) {
                            try {
                                call_user_func($callback, $result);
                            }
                            catch (Exception $ex) {}
                            catch (Throwable $ex) {}
                        }
                    }
                    if ($self->getTopic($name, $id) !== null) $cb();
                }
            };
            $topic->callbacks = array($callback);
            $this->topics[$name][$id] = $topic;
            $cb();
        }
        elseif (array_search($callback, $topic->callbacks, true) === false) {
            $topic->callbacks[] = $callback;
        }
    }
501106
static function create( $orderID, $statusID, $userID = false, $timestamp = false )
    {
        if ( $timestamp === false )
        {
            $timestamp = time();
        }
        if ( $userID === false )
        {
            $userID = eZUser::currentUserID();
        }
        $row = array( 'id' => null,
                      'order_id' => $orderID,
                      'status_id' => $statusID,
                      'modifier_id' => $userID,
                      'modified' => $timestamp );
        return new eZOrderStatusHistory( $row );
    }
141011
public function create($callId, $legId, $recordingId)
    {
        list(, , $body) = $this->HttpClient->performHttpRequest(
            Common\HttpClient::REQUEST_POST,
            "calls/$callId/legs/$legId/recordings/$recordingId/transcriptions"
        );
        return $this->processRequest($body);
    }
645025
public static function create_hold($mode, $channels, $response, $timeout = null)
    {
        $channels = self::parse_channels($channels);
        $ichannels = self::get_hold_channels($channels);
        $hold = array();
        $hold['mode'] = $mode;
        $hold['channels'] = $ichannels;
        if (!is_null($timeout)) {
            $hold['timeout'] = $timeout;
        }
        $iresponse = self::get_hold_response($response);
        $instruct = array();
        $instruct['hold'] = $hold;
        if (!is_null($iresponse)) {
            $instruct['response'] = $iresponse;
        }
        return json_encode($instruct);
    }
766886
def serialize(self, pid, record, links_factory=None):
        
        return simpledc.tostring(
            self.transform_record(pid, record, links_factory))
459262
public function createRequest($requestId, $url, UserEvent $event, EventQueue $queue)
    {
        $start = microtime(true);
        return new Request([
            'url' => $url,
            'responseCallback' => function ($headers, $code) use ($requestId, $start) {
                $end = microtime(true);
                $this->logDebug('[' . $requestId . ']Reponse (after ' . ($end - $start) . 's): ' . $code);
            },
            'resolveCallback' =>
                function ($data, $headers, $code) use ($requestId, $url, $event, $queue, $start) {
                    $end = microtime(true);
                    $message = '[';
                    $message .= $requestId;
                    $message .= ']Download complete (after ';
                    $message .= ($end - $start);
                    $message .= 's): ';
                    $message .= strlen($data);
                    $message .= ' in length length';
                    $this->logDebug($message);
                    $this->emitShorteningEvents($requestId, $url)->then(
                        function ($shortUrl) use ($url, $data, $headers, $code, $end, $start, $event, $queue) {
                            $this->sendMessage(
                                new Url($url, $data, $headers, $code, $end - $start, $shortUrl),
                                $event,
                                $queue
                            );
                        },
                        function () use ($url, $data, $headers, $code, $end, $start, $event, $queue) {
                            $this->sendMessage(new Url($url, $data, $headers, $code, $end - $start), $event, $queue);
                        }
                    );
                }
            ,
        ]);
    }
1305986
public function createRecord(
        $loggerNamespace,
        $loggerClass,
        $loggerMethod,
        $namespace,
        $class,
        $method,
        $level,
        $filename,
        $lineno,
        $msg,
        array $args,
        \Exception $exception = null
    ) {
        $record = new \Plop\Record(
            $loggerNamespace,
            $loggerClass,
            $loggerMethod,
            $namespace,
            $class,
            $method,
            $level,
            $filename,
            $lineno,
            $msg,
            $args,
            $this->interpolator,
            $exception
        );
        return $record;
    }
943510
public function createPdfRequest($url = null, $method = RequestInterface::METHOD_GET, $timeout = 5000)
    {
        return new PdfRequest($url, $method, $timeout);
    }
528776
def serialize(self, pid, record, links_factory=None, **kwargs):
        
        data = self.serializer.serialize(pid, record, links_factory)
        source = self._get_source(data)
        style = CitationStylesStyle(validate=False, **self._get_args(**kwargs))
        bib = CitationStylesBibliography(style, source, formatter.plain)
        citation = Citation([CitationItem(pid.pid_value)])
        bib.register(citation)

        return self._clean_result(''.join(bib.bibliography()[0]))
1338324
public function get($timeout = 10, $interval = 0.5)
    {
        $intervalUs = (int)($interval * 1000000);
        $iterationLimit = (int)($timeout / $interval);

        for ($i = 0; $i < $iterationLimit; $i++) {
            if ($this->ready()) {
                break;
            }
            usleep($intervalUs);
        }

        if (!$this->ready()) {
            throw new \Rhubarb\Exception\TimeoutException(
                sprintf(
                    'Task %s(%s) did not return after %s seconds',
                    $this->getId(),
                    (string)$this,
                    $timeout
                )
            );
        }
        return $this->responseBody->result;
    }
302581
public function loadById($pId)
    {
        if (! $pId instanceof Id) {
            $id = new Id($pId);
        } else {
            $id = $pId;
        }

        return $this->_loadByAttribute(static::IDFIELD, $id->getOrig());
    }
802304
public function poll(callable $probe, Timeout $timeout): void
    {
        $timeout->start();
        $lastException = null;

        while (true) {
            try {
                $probe();

                // the probe was successful, so we can return now
                return;
            } catch (Exception $exception) {
                // the probe was unsuccessful, we remember the last exception
                $lastException = $exception;
            }

            if ($timeout->hasTimedOut()) {
                throw new Interrupted('A timeout has occurred', 0, $lastException);
            }

            // we wait before trying again
            $timeout->wait();
        }
    }