protected function getObjectSafely($openCallback)
    {
        $elapsed = 0;
        $object = $this->getObject();
        if ($this->lock === false)
        {
            while ($object->isLocked())
            {
                $this->storage->close();
                usleep($object->getInterval());
                $this->storage->{$openCallback}();
                $object = $this->getObject();
                if ($object->getTimeout() > 0)
                {
                    $elapsed += $object->getInterval();
                    if (floor($elapsed / 1000000) >= $object->getTimeout())
                    {
                        throw new \Exception(sprintf("Can't access shared object, it is still locked after %d second(s).",
                           $object->getTimeout()));
                    }
                }
            }
        }
        return $object;
    }