pub async fn sleep(secs: u64)
Expand description
Suspends the current async task for the specified number of seconds.
This convenience function provides a simple interface for second-based delays,
using the same high-precision platform-native timing as Timer::after
.
§Arguments
secs
- The number of seconds to sleep
§Platform Integration
Uses the same platform-native scheduling as Timer
for consistent precision.
§Examples
use native_executor::timer::sleep;
async fn delayed_operation() {
println!("Starting operation");
sleep(2).await; // High-precision 2-second delay
println!("Operation resumed after 2 seconds");
}