public function execute(callable $code)
    {
        $this->looping = true;

        $deadline = microtime(true) + $this->timeout; // At this time, the lock will time out.
        $result = null;

        for ($i = 0; $this->looping && microtime(true) < $deadline; $i++) {
            $result = $code();
            if (!$this->looping) {
                break;
            }

            /*
             * Calculate max time remaining, don't sleep any longer than that.
             */
            $usecRemaining = \intval(($deadline - microtime(true))  * 1e6);

            if ($usecRemaining <= 0) {
                /*
                 * We've ran out of time.
                 */
                throw TimeoutException::create($this->timeout);
            }

            $min = min((int) self::MINIMUM_WAIT_US * 1.5 ** $i, self::MAXIMUM_WAIT_US);
            $max = min($min * 2, self::MAXIMUM_WAIT_US);

            $usecToSleep = \min($usecRemaining, \random_int($min, $max));

            usleep($usecToSleep);
        }

        if (microtime(true) >= $deadline) {
            throw TimeoutException::create($this->timeout);
        }

        return $result;
    }