-
Notifications
You must be signed in to change notification settings - Fork 653
Having both "sync" and "sink" in the API makes verbal discussion v. confusing #395
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
Comments
Heh, agreed :) FWIW I currently disambiguate with "sink with an I" and "sync with a Y", although it's not great. Agreed we should probably rename |
Pretty sure @alexcrichton suggested |
Oh right! |
Closing -- this is addressed in 0.2, rust-lang-nursery/futures-rfcs#1 |
@aturon how is this addressed? Afaik, the trait is still named |
The |
@aturon FWIW, the struggle is real when talking about I now always say "Sink with an I" and "Sync with a Y" when talking about futures. |
@carllerche heh, indeed! |
Ah sorry, I missed your point re: the Do we have any contenders for a different name for |
@aturon Alex originally proposed We obviously can't use |
(I really don't like |
@jsgf yeesh! I'm curious why you feel so strongly, and what you think would be a better replacement? |
@aturon The beauty of the futures model is that it's all pull based - it's the act of calling So, for example, unbounded and oneshot channels are fine, because their senders can never block. But the bounded channels are a complete pain to use because the Every time I've used It does mean that we need to move away from thinking about the "sending side" of a channel/pipe/socket/etc. Instead they all become the "consuming side" - they take ownership of a The main value of a sink-like endpoint is when interfacing blocking code into an async environment across threads via a channel. In that case a sync sink is fine, but that doesn't need a complex interface like |
@jsgf the |
OK, I'll take a look. When did those changes happen? |
@carllerche I don't think the recent changes to @jsgf When we were first designing That said, the traits do allow you to consume a |
@aturon I think it does :) @jsgf originally said:
My interpretation of that is that Sink has historically been difficult to use because send can fail. This has also been my experience and why I personally have never ended up using it. However, with the new trait, you can reconcile sinks with the surrounding async nature of things. Imagine a Now, getting a value and sending it becomes: my_value.join(sink.ready()).and_then(|(value, sink)| {
sink.start_send(value) // or send if you want to include flush as part of the logic.
}) Anyway, I am only hypothesizing based on the OP & my personal experience, so |
@carllerche I see, thanks! One thing I still worry a bit about: in general, after a complete send, you also need to ensure that you are continually polling to flush, even if you don't want to block on flushing. That's not hard to do when you're writing tasks manually, but I don't actually know how this is going to work with async/await notation... |
@aturon is this significantly different than Another question, can |
If an async fn converts to a future, it seems like it should be possible to have /cc @withoutboats |
@aturon The specific case related to In the end we ended up using an unbounded channel and tried to limit the number of in-flight things manually. But I think a channel wasn't really the right thing to use at all - all we really wanted was the ability to poll a stream/future across threads which would have avoided the notion of sending something at all. I'm curious about what the lifetime problems are with "stream consumer" model, and whether they're worse than with |
Hm, I guess I'd overlooked that |
I don't think it was clear at all in the RFC that unsync was going away and sync was just what would become futures-channel. |
@seanmonstar Oy, you're right. To be clear, |
I'm going to go ahead and close this out; we're not going to rename |
The other day I had a conversation in which we were a few mins in before we realized we were talking at cross purposes because of a sync/sink confusion.
Maybe rename futures::sync? Or "sink" -> "drain" (or something)?
The text was updated successfully, but these errors were encountered: