ntex-rs / ntex

framework for composable networking services
Apache License 2.0
1.98k stars 108 forks source link

`ntex::time::timeout` is not accurate #310

Closed khvzak closed 6 months ago

khvzak commented 6 months ago

An example:

#[ntex::main]
async fn main() -> Result<(), ()> {
    let fut = async {
        ntex::time::sleep(ntex::time::Millis(15)).await;
        1
    };
    let res = ntex::time::timeout(ntex::time::Millis(10), fut).await;
    println!("{res:?}");
    Ok(())
}

prints Ok(1) but should print Err(()). ntex latest v1.1.2, macOS x86_64 14.3, tokio.

Same example using tokio::time works fine.

fafhrd91 commented 6 months ago

it is not precise and it is explicit decision. resolution is 16 millis.

fafhrd91 commented 6 months ago

main purpose of the ntex timer is network timeouts and those usually within seconds

khvzak commented 6 months ago

Thanks for confirming!