@param object $owner
@param float  $timeout
@param string $type

@return object

@throws \ManaPHP\Pool\NotExistsException
772160
public function pop($owner, $timeout = null, $type = 'default')
    {
        $owner_id = spl_object_id($owner);

        if (!isset($this->_pool[$owner_id][$type])) {
            throw new NotExistsException(['`:type` pool of `:owner` is not exists', 'type' => $type, 'owner' => get_class($owner)]);
        }

        $queue = $this->_pool[$owner_id][$type];

        if (!$queue->isEmpty()) {
            return $queue->pop();
        }

        if (!$timeout) {
            return null;
        }

        $end_time = microtime(true) + $timeout;
        do {
            if (!$queue->isEmpty()) {
                return $queue->pop();
            }
            usleep(1000);
        } while ($end_time > microtime(true));

        if ($queue->isEmpty()) {
            throw new BusyException(['`:type` pool of `:owner` is busy', 'type' => $type, 'owner' => get_class($owner)]);
        } else {
            return $queue->pop();
        }
    }
554341
public function viewBlockAction($owner, $ownerId, $id)
    {
        /** @var BlockManager $manager */
        $manager = $this->get('opifer.content.block_manager');

        $object = $this->get('opifer.content.block_provider_pool')->getProvider($owner)->getBlockOwner($ownerId);

        /** @var Environment $environment */
        $environment = $this->get('opifer.content.block_environment');
        $environment->setDraft(true)->setObject($object);

        $block = $environment->getBlock($id);

        $environment->setBlockMode(Environment::MODE_MANAGE);

        /** @var AbstractBlockService $service */
        $service = $manager->getService($block);
        $service->setEnvironment($environment);

        $this->get('opifer.content.twig.content_extension')->setBlockEnvironment($environment);


        return new JsonResponse(['view' => $service->manage($block)->getContent()]);
    }
417415
public function timeout($timeout = null)
    {
        // Return value
        if (empty($timeout)) {
            return $this->timeout;
        }

        // Set value
        $this->timeout = $timeout;

        return $this;
    }
1199785
public function getPageByOwnerId( $ownerId, $config = [] ) {

		$owner		= $config[ 'owner' ] ?? false;
		$modelTable	= $this->getModelTable();

		if( $owner ) {

			$config[ 'conditions' ][ "$modelTable.holderId" ] = $ownerId;
		}
		else {

			$config[ 'conditions' ][ "$modelTable.createdBy" ] = $ownerId;
		}

		return $this->getPage( $config );
	}
209304
public static function fromOwnerAndName(string $owner, string $name): self
    {
        if (1 !== \preg_match(self::ownerRegEx(), $owner)) {
            throw new Exception\InvalidArgumentException(\sprintf(
                'Owner "%s" does not appear to be a valid owner.',
                $owner
            ));
        }

        if (1 !== \preg_match(self::nameRegEx(), $name)) {
            throw new Exception\InvalidArgumentException(\sprintf(
                'Name "%s" does not appear to be a valid name.',
                $name
            ));
        }

        return new self(
            $owner,
            $name
        );
    }
1046862
public function iterate($timeout)
    {

        // call parent method and sleep for the default timeout
        parent::iterate($timeout);

        // create the requested timer instance
        $this->synchronized(function ($self) {

            // create the timer, only if we're NOT dispatched
            if ($self->dispatched === false) {
                $self->timer = Timer::builder()
                    ->setNewTimer(true)
                    ->setId(Uuid::uuid4()->__toString())
                    ->setInitialDate($self->initialExpiration)
                    ->setRepeatInterval($self->intervalDuration)
                    ->setInfo($self->info)
                    ->setPersistent($self->persistent)
                    ->setTimerState(TimerState::CREATED)
                    ->setTimedObjectId($self->timerService->getTimedObjectInvoker()->getTimedObjectId())
                    ->build($self->timerService);

                // we're dispatched now
                $self->dispatched = true;
            }

        }, $this);

        // profile the size of the sessions
        if ($this->profileLogger) {
            $this->profileLogger->debug(
                sprintf('Size of session pool is: %d', sizeof($this->sessionPool))
            );
        }
    }
566843
public function designAction($owner, $ownerId)
    {
        /** @var BlockManager $blockManager */
        $blockManager = $this->get('opifer.content.block_manager');
        $manager = $this->get('opifer.content.content_manager');

        /** @var AbstractDesignSuite $suite */
        $suite = $this->get(sprintf('opifer.content.%s_design_suite', $owner));
        $suite->load($ownerId);

        $content = $manager->getRepository()->find($ownerId);

        $parameters = [
            'manager' => $blockManager,
            'toolset' => $blockManager->getToolset(),
            'id' => $suite->getSubject()->getId(),
            'owner' => $owner,
            'title' => $suite->getTitle(),
            'caption' => $suite->getCaption(),
            'permalink' => $suite->getPermalink(),
            'defaultDomain' => (($content && $content->getSite()) ? $content->getSite()->getDefaultDomain() : null),
            'url_properties' => $suite->getPropertiesUrl(),
            'url_cancel' => $suite->getCancelUrl(),
            'url' => $suite->getCanvasUrl(),
        ];

        return $this->render($this->getParameter('opifer_content.content_design_view'), $parameters);
    }
73935
public function iterate($timeout)
    {

        // call parent method and sleep for the default timeout
        parent::iterate($timeout);

        // create the requested timer instance
        $this->synchronized(function ($self) {

            // create the calendar timer, only if we're NOT dispatched
            if ($self->dispatched === false) {
                $self->timer = CalendarTimer::builder()
                    ->setAutoTimer($self->timeoutMethod != null)
                    ->setScheduleExprSecond($self->schedule->getSecond())
                    ->setScheduleExprMinute($self->schedule->getMinute())
                    ->setScheduleExprHour($self->schedule->getHour())
                    ->setScheduleExprDayOfWeek($self->schedule->getDayOfWeek())
                    ->setScheduleExprDayOfMonth($self->schedule->getDayOfMonth())
                    ->setScheduleExprMonth($self->schedule->getMonth())
                    ->setScheduleExprYear($self->schedule->getYear())
                    ->setScheduleExprStartDate($self->schedule->getStart())
                    ->setScheduleExprEndDate($self->schedule->getEnd())
                    ->setScheduleExprTimezone($self->schedule->getTimezone())
                    ->setTimeoutMethod($self->timeoutMethod)
                    ->setTimerState(TimerState::CREATED)
                    ->setId(Uuid::uuid4()->__toString())
                    ->setPersistent($self->persistent)
                    ->setTimedObjectId($self->timerService->getTimedObjectInvoker()->getTimedObjectId())
                    ->setInfo($self->info)
                    ->setNewTimer(true)
                    ->build($self->timerService);

                // we're dispatched now
                $self->dispatched = true;
            }

        }, $this);

        // profile the size of the sessions
        if ($this->profileLogger) {
            $this->profileLogger->debug(
                sprintf('Size of session pool is: %d', sizeof($this->sessionPool))
            );
        }
    }
41906
public function push($owner, $instance, $type = 'default')
    {
        if ($instance === null) {
            return $this;
        }

        $owner_id = spl_object_id($owner);

        if (!isset($this->_pool[$owner_id][$type])) {
            $queue = new \SplQueue();
            $this->_pool[$owner_id][$type] = $queue;
        } else {
            $queue = $this->_pool[$owner_id][$type];
        }

        $queue->push($instance);

        return $this;
    }
692378
public function setOwner($type, $id)
    {
        $this->ownerType = $type;
        $this->ownerId = $id;

        $this->server->getEventEmitter()->emit(new SessionOwnerEvent($this));

        return $this;
    }
720324
public function findByOwner(BlockInterface $owner, $version = false)
    {
        $blocks = $this->getRepository()->findBy(['owner' => $owner], ['sort' => 'asc']);

        if ($version) {
            foreach ($blocks as $key => $block) {
                $this->revertSingle($block, $version);

                if ($block->getDeletedAt() && $block->getDeletedAt() < new \DateTime) {
                    unset($blocks[$key]);
                }
            }
        }

        usort($blocks, function ($a, $b) {
            return ($a->getSort() < $b->getSort()) ? -1 : 1;
        });

        return $blocks;
    }
603070
public function withDefaultOwner(CanBeOwnerContract $owner = null)
    {
        $this->defaultOwner = $owner ?: $this->resolveDefaultOwner();
        if (isset($this->withDefaultOwnerOnCreate)) {
            $this->withDefaultOwnerOnCreate = false;
        }

        return $this;
    }
989084
public function timeout($timeout): ProcessBuilder
    {
        if ($timeout === null) {
            $this->timeout = null;

            return $this;
        }

        $timeout = (float) $timeout;

        if ($timeout < 0) {
            throw new DomainException('Timeout must be a positive number');
        }

        $this->timeout = $timeout;

        return $this;
    }
545832
public static void pauseTimer(final String type) {
    TransactionLogger instance = getInstance();
    if (instance == null) {
      return;
    }

    instance.components.get(type).pauseTimer();
  }
620148
@Override
    public IPromise<T> onTimeout(Consumer timeoutHandler) {
        return then( (r,e) -> {
            if ( e == Timeout.INSTANCE ) {
                timeoutHandler.accept(e);
            }
        });
    }
1180824
public function setTimeout($timeout)
    {
        $timeout = intval($timeout);
        if (!empty($timeout)) {
            $this->timeout = $timeout;
        }
    }
71048
public function send($timeout=null) 
	{
		$format = $this->params->getString("format",null);

		if (!strrpos($this->method, ".")) {
			$this->host = "socialize.".$this->apiDomain;
			$this->path = "/socialize.".$this->method;
		} else {
			$tokens = explode( ".", $this->method );
			$this->host = $tokens[0].".".$this->apiDomain;
			$this->path = "/".$this->method;
		}
		
		//set json as default format.
		if (empty($format))
		{
			$format =  "json";
			$this->setParam("format", $format);
		}
		if(!empty($timeout))
		{
			$this->traceField("timeout",$timeout);
		}
		
		if (empty($this->method) || (empty($this->apiKey) and empty($this->userKey)) )
		{
			return new GSResponse($this->method,null,$this->params,400002,null,$this->traceLog);
		}
		
		if ($this->useHTTPS && empty(GSRequest::$cafile)) 
		{
			return new GSResponse($this->method,null,$this->params,400003,null,$this->traceLog);
		}

		try 
		{
			$this->setParam("httpStatusCodes", "false");
			
			$this->traceField("userKey", $this->userKey);
			$this->traceField("apiKey", $this->apiKey);
			$this->traceField("apiMethod", $this->method);
			$this->traceField("params",$this->params);
			$this->traceField("useHTTPS", $this->useHTTPS);

			$responseStr = $this->sendRequest("POST", $this->host, $this->path, $this->params, $this->apiKey, $this->secretKey, $this->useHTTPS,$timeout, $this->userKey);
			
			return new GSResponse($this->method,$responseStr,null,0,null,$this->traceLog);
		}
		catch (Exception $ex) {
			$errcode = 500000;
			$errMsg = $ex->getMessage();
		    $length = strlen("Operation timed out");
		    if((substr($ex->getMessage(), 0, $length) === "Operation timed out"))
			{
				 $errcode = 504002;
				 $errMsg = "Request Timeout";
			}
	
			return new GSResponse($this->method,null,$this->params,$errcode,$errMsg, $this->traceLog);
		}
	}