class Google::Cloud::Env::LazyValue
def get *extra_args
-
(Exception)- if an error happened while computing the value
Returns:
-
(Object)- the value
def get *extra_args @mutex.synchronize do # Wait for any backfill to complete, and handle expiration first # because it might change the state. wait_backfill do_expire if should_expire? # Main state handling if @retries.finished? # finished state: return value or error return cached_value elsif !@compute_notify.nil? # computing state: wait for the computing thread to finish then # return its result wait_compute return cached_value else # pending state cur_time = Process.clock_gettime Process::CLOCK_MONOTONIC # waiting for the next retry: return current error raise @error if @expires_at && cur_time < @expires_at # no delay: compute in the current thread enter_compute cur_time # and continue below end end # Gets here if we just transitioned from pending to compute perform_compute extra_args end