private function flush(int &$flushCounter, bool $partial): void
    {
        if (null === $this->flush) {
            return;
        }

        ($this->flush)($partial);
        $this->eventDispatcher->dispatch(new FlushEvent($this, $flushCounter, $partial));
        $flushCounter = 0;
    }