Set the priority of an object in the queue

@param ObjectHandlable $object    A command object
@param integer          $priority  The priority
@return ObjectQueue
160059
public function setPriority(ObjectHandlable $object, $priority)
    {
        if($handle = $object->getHandle())
        {
            if($this->__priority_list->offsetExists($handle))
            {
                $this->__priority_list->offsetSet($handle, $priority);
                $this->__priority_list->asort();
            }
        }

        return $this;
    }
1351255
public function insert(AnObjectHandlable $object)
    {
        $result = false;

        if ($handle = $object->getHandle()) {
            $this->_object_set->offsetSet($handle, $object);
            $result = true;
        }

        return $result;
    }
1168694
public function extract(AnObjectHandlable $object)
    {
        $handle = $object->getHandle();

        if ($this->_object_set->offsetExists($handle)) {
            $this->_object_set->offsetUnset($handle);
        }

        return $this;
    }
1267844
protected function _lock($object, $lock)
    {
        if ($lock) {
            self::$_locks[$object->getHandle()] = true;
        } else {
            unset(self::$_locks[$object->getHandle()]);
        }
    }
531243
public function priority($priority = null)
    {
        $headers = $this->headers();
        if (!func_num_args()) {
            return $headers['X-Priority'];
        }
        $headers['X-Priority'] = (string) $priority;
        return $this;
    }
772527
public function setPriority($stateId, $priority)
    {
        $objectState = $this->load($stateId);
        $groupObjectStates = $this->loadObjectStates($objectState->groupId);

        $priorityList = array();
        foreach ($groupObjectStates as $index => $groupObjectState) {
            // Update given state and push all other states with same or higher priority down
            if ($objectState->id === $groupObjectState->id) {
                $priorityList[$groupObjectState->id] = (int)$priority;
            } else {
                $priorityList[$groupObjectState->id] = ($index < $priority ? $index : $index + 1);
            }
        }

        asort($priorityList, SORT_NUMERIC);

        foreach (array_keys($priorityList) as $objectStatePriority => $objectStateId) {
            $this->objectStateGateway->updateObjectStatePriority($objectStateId, $objectStatePriority);
        }
    }
888865
public function priority($priority)
    {
        if (!$this->isNumber($priority)) {
            throw new EventManagerException(EventManagerException::MSG_INVALID_ARG, [
                    '$priority',
                    'integer'
                ]
            );
        }

        if ($priority <= 100 || $priority >= 1000) {
            throw new EventManagerException(EventManagerException::INVALID_PRIORITY_VALUE);
        }
        $this->priority = $priority;

        return $this;
    }
377446
protected function createQueue($priority)
    {
        if (!$this->queues[$priority]) {
            $key = $this->getIntChannels()[$priority];
            $this->queues[$priority] = msg_get_queue($key);
        }

        return $this->queues[$priority];
    }
166629
public function merge($arrayOrObjectVar, $priority = self::MERGE_ARGUMENT)
    {
        if (is_object($arrayOrObjectVar)) {
            $arrayVar = $arrayOrObjectVar->toArray();
        } else {
            $arrayVar = $arrayOrObjectVar;
        }
        if ($priority == 1) {
            $this->arrayVar = array_merge($this->arrayVar, $arrayOrObjectVar);
        } else if ($priority == 2) {
            $this->arrayVar = array_merge($arrayOrObjectVar, $this->arrayVar);
        } else if ($priority == 3) {
            $arrayMerge = array();
            $arrayIndex = 0;
            foreach ($this->arrayVar as $value) {
                $arrayMerge[$arrayIndex] = $value;
                $arrayIndex++;
            }
            foreach ($arrayVar as $value) {
                $arrayMerge[$arrayIndex] = $value;
                $arrayIndex++;
            }
            $this->arrayVar = $arrayMerge;
        }
    }
304996
public function priority($level = 3)
    {
        $this->callbacks[] = function ($message) use ($level) {
            $message->setPriority($level);
        };

        return $this;
    }
816271
public function getPriority(ObjectHandlable $object)
    {
        $result = false;

        if($handle = $object->getHandle())
        {
            if($this->__priority_list->offsetExists($handle)) {
                $result = $this->__priority_list->offsetGet($handle);
            }
        }

        return $result;
    }
1130072
protected function createQueue($priority)
    {
        if (!$this->queues[$priority]) {
            $this->queues[$priority] = new \SplQueue();
            $this->queues[$priority]->setIteratorMode(\SplQueue::IT_MODE_DELETE);
        }

        return $this->queues[$priority];
    }
757903
public function offsetUnset($object)
    {
        if (!$object instanceof ObjectHandlable) {
            throw new \InvalidArgumentException('Object needs to implement ObjectHandlable');
        }

        unset($this->__data[$object->getHandle()]);
        return $this;
    }
1198083
public function add($listener, $priority): self
    {
        // transfer to object. like string/array
        if (!\is_object($listener)) {
            $listener = new LazyListener($listener);
        }

        if (!$this->has($listener)) {
            // Compute the internal priority as an array. 计算内部优先级为一个数组。
            // @see http://php.net/manual/zh/splpriorityqueue.compare.php#93999
            $priorityData = [(int)$priority, $this->counter--];

            $this->store->attach($listener, $priorityData);
            $this->queue->insert($listener, $priorityData);
        }

        return $this;
    }
6417
public function detach($priority)
    {
        if ($this->started) {
            throw new RuntimeException('Unable during invoking.');
        }
        if (isset($this->queue[$priority])) {
            unset($this->queue[$priority]);
            $this->sortedQueue = null;
        }

        return $this;
    }
1039896
public function withPriority($priority)
    {
        Assertion::float($priority);
        Assertion::greaterOrEqualThan($priority, UrlInterface::PRIORITY_MIN);
        Assertion::lessOrEqualThan($priority, UrlInterface::PRIORITY_MAX);
        Assertion::same($priority, \round($priority, 1));

        $instance = clone $this;

        $instance->priority = $priority;

        return $instance;
    }
807652
public function offsetSet($offset, $object)
    {
        if (!$object instanceof ObjectHandlable) {
            throw new \InvalidArgumentException('Object needs to implement ObjectHandlable');
        }

        $this->__data[$object->getHandle()] = $object;
        return $this;
    }