MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / sleep

Function sleep

crates/opencode-provider/src/retry.rs:55–70  ·  view source on GitHub ↗

Sleep for `ms` milliseconds, returning early if the `cancel` receiver signals `true`.

(ms: u64, mut cancel: watch::Receiver<bool>)

Source from the content-addressed store, hash-verified

53/// Sleep for `ms` milliseconds, returning early if the `cancel` receiver
54/// signals `true`.
55pub async fn sleep(ms: u64, mut cancel: watch::Receiver<bool>) {
56 let capped = ms.min(RETRY_MAX_DELAY);
57 let duration = std::time::Duration::from_millis(capped);
58
59 tokio::select! {
60 _ = tokio::time::sleep(duration) => {}
61 _ = async {
62 while !*cancel.borrow_and_update() {
63 if cancel.changed().await.is_err() {
64 // Sender dropped – treat as cancellation.
65 return;
66 }
67 }
68 } => {}
69 }
70}
71
72// ---------------------------------------------------------------------------
73// delay – compute how long to wait before the next retry

Callers 13

test_watch_directoryFunction · 0.85
wait_for_server_readyFunction · 0.85
handle_debug_commandFunction · 0.85
with_retryFunction · 0.85
with_retry_and_hookFunction · 0.85
receiveMethod · 0.85
touch_fileMethod · 0.85
kill_process_treeFunction · 0.85
get_lsp_diagnostics_implFunction · 0.85

Calls

no outgoing calls

Tested by 2

test_watch_directoryFunction · 0.68