private function wait(
        callable $isCompleteFn,
        callable $reloadFn,
        Job $job,
        $maxRetries
    ) {
        if (!$isCompleteFn()) {
            if ($maxRetries === null) {
                $maxRetries = Job::MAX_RETRIES;
            }

            $retryFn = function () use ($isCompleteFn, $reloadFn, $job) {
                $reloadFn();

                if (!$isCompleteFn()) {
                    throw new JobException('Job did not complete within the allowed number of retries.', $job);
                }
            };

            (new ExponentialBackoff($maxRetries))
                ->execute($retryFn);
        }
    }