protected function tryToAcquireLock(bool $exclusiveLock): bool
    {
        $this->filePointer = @fopen($this->lockFileName, 'w');
        if ($this->filePointer === false) {
            throw new LockNotAcquiredException(sprintf('Lock file "%s" could not be opened', $this->lockFileName), 1386520596);
        }

        $this->applyFlock($exclusiveLock);

        $fstat = fstat($this->filePointer);
        $stat = @stat($this->lockFileName);
        // Make sure that the file did not get unlinked between the fopen and the actual flock
        // This will always be true on windows, because 'ino' stat will always be 0, but unlink is not possible on opened files anyway
        if ($stat !== false && $stat['ino'] === $fstat['ino']) {
            return true;
        }

        flock($this->filePointer, LOCK_UN);
        fclose($this->filePointer);
        $this->filePointer = null;

        usleep(100 + rand(0, 100));
        return false;
    }