protected function enqueue($eventName, $resourceOrEvent)
    {
        if (!$this->isOpened()) {
            throw new RuntimeException("The event queue is closed.");
        }

        if (!preg_match('~^[a-z_]+\.[a-z_]+\.[a-z_]+$~', $eventName)) {
            throw new InvalidArgumentException("Unexpected event name '{$eventName}'.");
        }

        if ($resourceOrEvent instanceof ResourceInterface) {
            $resource = $resourceOrEvent;
        } elseif ($resourceOrEvent instanceof ResourceEventInterface) {
            $resource = $resourceOrEvent->getResource();
        } else {
            throw new InvalidArgumentException("Expected instanceof ResourceInterface or ResourceEventInterface");
        }

        $oid = spl_object_hash($resource);

        // TODO we are enqueueing into en empty queue (cleared by the flush method)
        //      so duplication and conflict can't be resolved
        // TODO see persistAndRecompute (.., $andSchedule = false)

        // Don't add twice
        if (isset($this->queue[$eventName]) && isset($this->queue[$eventName][$oid])) {
            return;
        }

        $this->preventEventConflict($eventName, $oid);

        if (!isset($this->queue[$eventName])) {
            $this->queue[$eventName] = [];
        }

        $this->queue[$eventName][$oid] = $resourceOrEvent;
    }