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

Make blocking public? #65

Closed
zkat opened this issue Aug 17, 2019 · 6 comments · Fixed by #251
Closed

Make blocking public? #65

zkat opened this issue Aug 17, 2019 · 6 comments · Fixed by #251
Labels
api design Open design questions enhancement New feature or request

Comments

@zkat
Copy link

zkat commented Aug 17, 2019

Hi! I was using async-std in my cacache library. One of the things that I'm trying to do is implement AsyncWrite for it, but it turns out I'm using a tmpfile library that does sync i/o. Because of that, I pretty much copy-pasted the AsyncWrite impl for async-std's File, and it turns out with the latest version, task::blocking is now private, so I can't just... do that. (To clarify, I was using async-std pre-release, when I needed to use async-pool for this, and I just started porting the code over tonight when I ran into this).

For the sake of compatibility, it would be nice to have this available. My code that's doing this is over here, in case there turns out to be a Better Way™ to do what I'm trying to do that hopefully doesn't involve reimplementing tmpfile logic: https://github.com/zkat/cacache-rs/blob/zkat/async/src/content/write.rs#L147-L256

Cheers!

@sdroege
Copy link

sdroege commented Aug 18, 2019

It would also be quite useful for me to have the task::blocking module public. It could be re-implemented externally around a thread pool and oneshot channels of course, but doing that everywhere seems a bit suboptimal (performance- and code duplication-wise).

It's pub(crate) since the very first commit in this repo, so the rationale why it is not public anymore is lost from history unfortunately.

I assume it's not public anymore because there was not enough certainty that this is a good enough API to be stabilized as 1.0 soonish? Were there specific concerns about it? To me it looks like exactly how you'd expect such an API to look like.

@sdroege
Copy link

sdroege commented Aug 18, 2019

Maybe (also in relation to #60), it would make sense to at least give access to some internals and "uncertain-if-good-enough-for-1.0"-APIs via a feature flag.

That way there can be some experimentation with the API and it isn't required for everybody to duplicate the implementation.

@yoshuawuyts
Copy link
Contributor

This has come up several times, and we need to come up with a public API for this. This seems something we'll want to do in the medium term for sure; though we could cheat it by introducing the current API as "unstable" first (which seems almost guaranteed like it would change).

@stjepang do you have any thoughts?

@yoshuawuyts yoshuawuyts added the api design Open design questions label Sep 18, 2019
@dvc94ch
Copy link

dvc94ch commented Sep 26, 2019

Can you also expose the net::driver::Watcher? I'm currently trying to async signal handling to work properly. The signal-hooks crate implements Evented, so it would be useful to be able to wrap that in the Watcher. The other thing I'm trying to get to work is flock. Not sure what the best way to do that is. Either implementing Evented or just using blocking.

@dignifiedquire
Copy link
Member

👍 on exposing net::driver::Watcher, implementing #22 using similar techniques as tokio-process uses, requires to use signal-hooks or sth similar, so this is somewhat blocked on this, unless the signal handling is pulled into here (bad idea imho though)

@yoshuawuyts
Copy link
Contributor

I've filed #251 for the blocking function. We'll need to come up with something else to expose driver though (got some ideas; but got to test them out first.)

Hope this helps!

moh-eulith pushed a commit to moh-eulith/async-std that referenced this issue Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api design Open design questions enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants