Skip to content

Commit

Permalink
Expose guard
Browse files Browse the repository at this point in the history
  • Loading branch information
zakstucke committed Jun 22, 2024
1 parent a4cf143 commit 31a19e3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rust/bitbazaar/misc/refreshable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use std::sync::{atomic::AtomicU64, Arc};
use arc_swap::ArcSwap;
use futures::Future;

pub use arc_swap::Guard as RefreshableGuard;

use crate::prelude::*;

/// A data wrapper that automatically updates the data given out when deemed stale.
Expand Down Expand Up @@ -52,7 +54,7 @@ impl<T, Fut: Future<Output = RResult<T, AnyErr>>, F: Fn() -> Fut> Refreshable<T,
///
/// NOTE: the implementation of the guards means not too many should be alive at once, and keeping across await points should be discouraged.
/// If you need long access to the underlying data, consider cloning it.
pub async fn get(&self) -> RResult<arc_swap::Guard<Arc<T>>, AnyErr> {
pub async fn get(&self) -> RResult<RefreshableGuard<Arc<T>>, AnyErr> {
// Refresh if now stale:
if utc_now_ms()
- self
Expand Down

0 comments on commit 31a19e3

Please sign in to comment.