Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add _timeout variants to blocking executions #2911

Open
wyfo opened this issue Jan 7, 2025 · 0 comments
Open

Add _timeout variants to blocking executions #2911

wyfo opened this issue Jan 7, 2025 · 0 comments

Comments

@wyfo
Copy link

wyfo commented Jan 7, 2025

A common pattern for blocking functions in Rust is to provide a _timeout variant, see rust-lang/rust#46316. However, this crate currently doesn't provide a way to interrupt blocking executions, which prevents it to be used in some workflows.

Here is the context of my main use case:
I've implemented a channel, and because it's a channel, the synchronization is naturally implemented using asynchronous code and primitives like AtomicWaker. However, I also needed to expose a synchronous API, with timeout/deadline capabilities. Because futures_executor::block_on didn't have a _timeout counterpart, I couldn't rely on it, and had to write the synchronous API (using thread::park and reimplementing AtomicWaker) myself.
This feature request would simplify things a lot, allowing me to fully delegate the synchronous implementation to the future_executor crate. (Performance may be a little bit worse, because of mandatory TLS access even if waker is not used, but the simplification should be worth it)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant