MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / wait_for_database

Method wait_for_database

atomic-repository/src/repository/mod.rs:994–1010  ·  view source on GitHub ↗
(
        timeout: std::time::Duration,
        mut open: impl FnMut() -> Result<Self, RepositoryError>,
    )

Source from the content-addressed store, hash-verified

992 }
993
994 fn wait_for_database(
995 timeout: std::time::Duration,
996 mut open: impl FnMut() -> Result<Self, RepositoryError>,
997 ) -> Result<Self, RepositoryError> {
998 let start = std::time::Instant::now();
999 loop {
1000 match open() {
1001 Err(RepositoryError::DatabaseBusy) if start.elapsed() < timeout => {
1002 std::thread::sleep(
1003 std::time::Duration::from_millis(10)
1004 .min(timeout.saturating_sub(start.elapsed())),
1005 );
1006 }
1007 result => return result,
1008 }
1009 }
1010 }
1011
1012 /// Open for a workspace transaction, waiting for transient writers.
1013 ///

Callers

nothing calls this directly

Calls 1

openFunction · 0.85

Tested by

no test coverage detected