// At most one of LoadSync/LoadAsync may be called for any given // LoadingValueReference. T LoadSync(string key, LoadingValueReference <T> loading_value_reference, CacheLoader <T> loader) { IFuture <T> loading_future = loading_value_reference.LoadFuture(key, loader); return(GetUninterruptibly(key, loading_value_reference, loading_future)); }
IFuture <T> LoadAsync(string key, LoadingValueReference <T> loading_value_reference, CacheLoader <T> loader) { IFuture <T> loading_future = loading_value_reference.LoadFuture(key, loader); loading_future.AddListener(delegate() { try { T new_value = GetUninterruptibly(key, loading_value_reference, loading_future); // update loading future for the sake of other pending requests. loading_value_reference.Set(new_value); } catch (Exception exception) { MustLogger.ForCurrentProcess.Warn("Exception thrown during refresh", exception); } }, Executors.SameThreadExecutor()); return(loading_future); }