Skip to content

[Docs] Document any blocking / non-blocking behavior #692

@teohhanhui

Description

@teohhanhui

The claim at https://github.com/algesten/str0m#can-i-utilize-str0m-with-any-rust-async-runtime:

Can I utilize str0m with any Rust async runtime?

Absolutely! str0m is fully sync, ensuring that it integrates seamlessly with any Rust async runtime you opt for.

However, calling a sync function from within an async task is only safe to do when it's non-blocking.

From https://ryhl.io/blog/async-what-is-blocking/:

To give a sense of scale of how much time is too much, a good rule of thumb is no more than 10 to 100 microseconds between each .await. That said, this depends on the kind of application you are writing.

Perhaps this should be documented for functions / methods where it might be relevant? Or at least, the claim on the README should be modified to make it clear that it's not generally safe to call any sync function from async code, unless it won't block on I/O (which is fine, this library is sans I/O) and won't perform any CPU-heavy computation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions