修改消息可见时间
@param string $receiptHandle
@param int $visibilityTimeout
@return bool
512374
public function changeMessageVisibility($receiptHandle, $visibilityTimeout)
    {
        $this->deleteMessage($receiptHandle);
        if ($visibilityTimeout > 0) {
            $this->client->zadd($this->queueName . ':delayed', [$receiptHandle => time() + $visibilityTimeout]);
        } else {
            $this->client->rpush($this->queueName, [$receiptHandle]);
        }
    }
177229
protected T _getResultWithTimeout(final long timeout) throws TimeoutException {
        if(timeout <= 0)
            cond.waitFor(this::hasResult);
        else if(!cond.waitFor(this::hasResult, timeout, TimeUnit.MILLISECONDS))
            throw new TimeoutException();
        return result;
    }
1093100
public function processTime($timeout=NULL) {
		if (is_null($timeout)) {
			return $this->__process(NULL);
		} else {
			return $this->__process($timeout * 1000000);
		}
	}
463992
protected function _engineRender($engines, $viewPath, $silence, $mustClean, $cache)
    {
        $basePath = $this->_basePath;
        $notExists = true;

        if (is_object($cache)) {
            $renderLevel = intval($this->_renderLevel);
            $cacheLevel = intval($this->_cacheLevel);
            if ($renderLevel >= $cacheLevel) {
                if ($cache->isStarted() === false) {
                    $viewOptions = $this->_options;
                    if (is_array($viewOptions)) {
                        if (isset($viewOptions['cache'])) {
                            $cacheOptions = $viewOptions['cache'];
                            if (is_array($cacheOptions)) {
                                if (isset($cacheOptions['key'])) {
                                    $key = $cacheOptions['key'];
                                }
                                if (isset($cacheOptions['lifetime'])) {
                                    $lifeTime = $cacheOptions['lifetime'];
                                }
                            }

                            if (!isset($key) || !$key) {
                                $key = md5($viewPath);
                            }

                            if (!isset($lifeTime)) {
                                $lifeTime = 0;
                            }

                            $cachedView = $cache->start($key, $lifeTime);
                            if (!$cachedView) {
                                $this->_content = $cachedView;
                                return null;
                            }
                        }

                        if (!$cache->isFresh()) {
                            return null;
                        }
                    }
                }
            }
        }
        $viewParams = $this->_viewParams;
        $eventsManager = $this->_eventsManager;

        foreach ($engines as $extension => $engine) {
            $viewEnginePath = $basePath . $this->resolveFullViewPath($viewPath) . $extension;

            if (file_exists($viewEnginePath)) {
                if (is_object($eventsManager)) {
                    $this->_activeRenderPath = $viewEnginePath;
                    if ($eventsManager->fire("view:beforeRenderView", $this, $viewEnginePath) === false) {
                        continue;
                    }
                }
                $engine->render($viewEnginePath, $viewParams, $mustClean);

                $notExists = false;
                if (is_object($eventsManager)) {
                    $eventsManager->fire("view:afterRenderView", $this);
                }
                break;
            }
        }
        if ($notExists) {
            if (is_object($eventsManager)) {
                $this->_activeRenderPath = $viewEnginePath;
                $eventsManager->fire("view:notFoundView", $this, $viewEnginePath);
            }

            if (!$silence) {
                throw new Exception(sprintf("View %s was not found in the views directory", $viewEnginePath));
            }
        }
    }
1073385
public function deleteMessage($receiptHandle)
    {
        try {
            $this->queue->deleteMessage($receiptHandle);
            return true;
        } catch (MnsException $e) {
            Yii::trace(sprintf('Delete Message Failed:  `%s`...', $e));
            return false;
        }
    }
828777
public function tableRecognition($image, $options=array(), $timeout=10000){
        $result = $this->tableRecognitionAsync($image);
        if(isset($result['error_code'])){
            return $result;
        }
        $requestId = $result['result'][0]['request_id'];
        $count = ceil($timeout / 1000);
        for($i=0; $i<$count; $i++){
            $result = $this->getTableRecognitionResult($requestId, $options);
            // 完成
            if($result['result']['ret_code'] == 3){ 
                break;
            }
            sleep(1);
        }
        return $result;
    }
419515
function wait($timeout = 0.5)
    {
        $st = microtime(true);
        $success_num = 0;

        while (count($this->waitList) > 0)
        {
            $write = $error = $read = array();
            foreach ($this->waitList as $obj)
            {
                /**
                 * @var $obj RPC_Result
                 */
                if ($obj->socket !== null)
                {
                    $read[] = $obj->socket;
                }
            }
            if (empty($read))
            {
                break;
            }
            //去掉重复的socket
            Tool::arrayUnique($read);
            //等待可读事件
            $n = $this->select($read, $write, $error, $timeout);
            if ($n > 0)
            {
                //可读
                foreach($read as $connection)
                {
                    $data = $this->recvPacket($connection,$timeout);
                    //socket被关闭了
                    if ($data === "")
                    {
                        foreach($this->waitList as $retObj)
                        {
                            if ($retObj->socket == $connection)
                            {
                                $retObj->code = RPC_Result::ERR_CLOSED;
                                unset($this->waitList[$retObj->requestId]);
                                $this->closeConnection($retObj->server_host, $retObj->server_port);
                                //执行after钩子函数
                                $this->afterRequest($retObj);
                            }
                        }
                        continue;
                    }
                    elseif ($data === false)
                    {
                        continue;
                    }
                    $header = unpack(RPCServer::HEADER_STRUCT, substr($data, 0, RPCServer::HEADER_SIZE));
                    //不在请求列表中，错误的请求串号
                    if (!isset($this->waitList[$header['serid']]))
                    {
                        trigger_error(__CLASS__ . " invalid responseId[{$header['serid']}].", E_USER_WARNING);
                        continue;
                    }
                    $retObj = $this->waitList[$header['serid']];
                    //成功处理
                    $this->finish(RPCServer::decode(substr($data, RPCServer::HEADER_SIZE), $header['type']), $retObj);
                    $success_num++;
                }
            }
            //发生超时
            if ((microtime(true) - $st) > $timeout)
            {
                foreach ($this->waitList as $obj)
                {
                    $obj->code = ($obj->socket->isConnected()) ? RPC_Result::ERR_TIMEOUT : RPC_Result::ERR_CONNECT;
                    $this->closeConnection($obj->server_host, $obj->server_port);
                    //执行after钩子函数
                    $this->afterRequest($obj);
                }
                //清空当前列表
                $this->waitList = array();
                foreach($read as $r)
                {
                    $this->freeConnection($r);
                }
                return $success_num;
            }
        }

        foreach($read as $r)
        {
            $this->freeConnection($r);
        }

        //未发生任何超时
        $this->waitList = array();
        $this->requestIndex = 0;
        return $success_num;
    }
791265
public function waitUntilStatus($by, $value, $displayed = true, $timeout = 0)
    {
        try {
            /** @var \PHPUnit_Extensions_Selenium2TestCase_Element $element */
            return $this->waitUntil(function() use ($by, $value, $displayed) {
                /** @var \PHPUnit_Extensions_Selenium2TestCase_Element $element */
                $element = $this->$by($value);

                if ($displayed) {
                    return $element->displayed() && $element->enabled() ? $element : null;
                }

                return !$element->displayed() ? $element : null;
            }, empty($timeout) ? self::TIMEOUT_ELEMENT : $timeout);
        } catch (\Exception $exception) {
            $this->fail(
                $exception->getMessage() . ' | ' .
                __FUNCTION__ . ' | ' . $by . ' | ' . $value . ' | ' . ($displayed ? 'displayed' : 'hidden')
            );

            return $this->$by($value);
        }
    }
79391
def receipt(self, msg):
        
        body = msg['body'].replace(NULL, '')

        brief_msg = ""
        if 'receipt-id' in msg['headers']:
            brief_msg = msg['headers']['receipt-id']

        self.log.info("Received server receipt message - receipt-id:%s\n\n%s" % (brief_msg, body))

        returned = NO_RESPONSE_NEEDED
        if self.testing:
            returned = 'receipt'

        return returned
1265383
public function unlock($passphrase, $timeout)
    {
        $args = [
            (string)$passphrase,
            (int)$timeout
        ];
        
        try {
            $this->rpc->query("walletPassPhrase", $args);
        } catch (Exceptions\RPCException $e) {
            if ($e->getCode() != RPCErrorCodes::WALLET_ALREADY_UNLOCKED) {
                throw $e;
            }
        }
        
        return true;
    }
68312
public function basic_cancel($consumer_tag, $nowait = false, $noreturn = false)
    {
        list($class_id, $method_id, $args) = $this->protocolWriter->basicCancel($consumer_tag, $nowait);
        $this->send_method_frame(array($class_id, $method_id), $args);

        if ($nowait || $noreturn) {
            unset($this->callbacks[$consumer_tag]);
            return $consumer_tag;
        }

        return $this->wait(array(
            $this->waitHelper->get_wait('basic.cancel_ok')
        ), false, $this->channel_rpc_timeout);
    }
270994
public function restore(string $data, int $timeout = 0): bool
    {
        return $this->handle->restore($this->name, $timeout, $data);
    }
688384
public function acknowledge($delivery_tag, $type = 1)
    {
        if ($type == 1) {
            //确认消息
            return $this->amqpQueue->ack($delivery_tag);
        } elseif ($type == 2) {
            //恢复消息
            return $this->amqpQueue->nack($delivery_tag);
        } elseif ($type == 3) {
            //确认取消
            return $this->amqpQueue->reject($delivery_tag);
        } else {
            throw new \AMQPQueueException('Undefined Acknowledge type');
        }
    }
1032262
public function batchDeleteMessage($receiptHandles)
    {
        $successCount = 0;
        foreach ($receiptHandles as $receiptHandle) {
            if ($this->deleteMessage($receiptHandle)) {
                $successCount++;
            }
        }
        return $successCount;
    }
302971
@Override
    public java.util.concurrent.Future<DeleteMessageResult> deleteMessageAsync(String queueUrl, String receiptHandle,
            com.amazonaws.handlers.AsyncHandler<DeleteMessageRequest, DeleteMessageResult> asyncHandler) {

        return deleteMessageAsync(new DeleteMessageRequest().withQueueUrl(queueUrl).withReceiptHandle(receiptHandle), asyncHandler);
    }
200032
function emit(resolver) {
        var items = resolver.status === STATUS.FULFILLED
            ? resolver.fulfillList
            : resolver.rejectList;

        emitGlobalEvent(resolver);

        if (!items.length) {
            return;
        }

        // 触发注册的回调函数必须
        // 在状态改变完成后
        // see #2.2.2 #2.2.3 #2.2.4
        Resolver.nextTick(
            function () {
                var item;
                while (item = items.shift()) {
                    item(resolver.data);
                }
            }
        );
    }
1264791
public static function lock($lock, \Closure $callback, $timeout = 30) {
        try {
            $redis = RedisClient::getRedis();
            if ($redis) {
                $start = time();
                $cnt   = $redis->incr($lock);
                $wait  = false;
                while ($cnt != 1) {
                    usleep(200);
                    $wait = true;
                    if ((time() - $start) > $timeout) {
                        break;//超时
                    }
                    if (!$redis->exists($lock)) {//锁释放方式为删除
                        $cnt = $redis->incr($lock);
                    }
                }
                if ($cnt != 1) {
                    return false;
                }
                $redis->setTimeout($lock, $timeout * 2);//防止死锁
                try {
                    return $callback($wait, $redis);
                } catch (\Exception $e) {
                    log_warn($e->getMessage(), 'redis_lock');

                    return false;
                } finally {
                    $redis->del($lock);
                }
            }
        } catch (\Exception $e) {
            log_warn($e->getMessage(), 'redis_lock');
        }

        return false;
    }