Giter Site home page Giter Site logo

Rename forget to ensure. about futures-rs HOT 11 CLOSED

rust-lang avatar rust-lang commented on June 12, 2024 12
Rename forget to ensure.

from futures-rs.

Comments (11)

dwrensha avatar dwrensha commented on June 12, 2024 13

detach() maybe?

from futures-rs.

chrivers avatar chrivers commented on June 12, 2024 1

Maybe .background()? Or do you think it gives too much of a kernel scheduler vibe?

from futures-rs.

aturon avatar aturon commented on June 12, 2024

Agreed on the name -- I like ensure! Though it's a little unclear to me what the ultimate fate of this method should be...

from futures-rs.

alexcrichton avatar alexcrichton commented on June 12, 2024

Yeah I agree that forget isn't exactly the greatest name, it's already showing its age as it was originally intended for something completely different! I agree though with @aturon that we should likely figure out the final story for this method first though before tweaking it.

from futures-rs.

alexcrichton avatar alexcrichton commented on June 12, 2024

We've now since removed forget, so no longer an issue!

from futures-rs.

nabijaczleweli avatar nabijaczleweli commented on June 12, 2024

xD

from futures-rs.

Stebalien avatar Stebalien commented on June 12, 2024

Out of curiosity, is there a new way to say "complete this future in the background"?

Specifically, it would be nice to have some form of dynamically sized (with an optional maximum?) unordered version of Stream::buffered that just completes futures returned from a stream as fast as possible. That is, some way to asynchronously dispatch requests and then handle them in order of completion. As far as I can tell, this doesn't exist.

Note: I'm asking because this feature allowed for an inferior version of that primitive through channels (forget a future and have it reply back through a channel when done).

from futures-rs.

aturon avatar aturon commented on June 12, 2024

@Stebalien The problem with forget is it wasn't really "in the background"; the future execute on whatever thread last happened to wake it up. Part of the move with executors is to have a much more clear picture of where futures are being executed.

So, when you say "in the background", what do you have in mind?

from futures-rs.

Stebalien avatar Stebalien commented on June 12, 2024

@aturon I need a way to drive an unbounded number of futures at the same time. I didn't actually like how forget worked as I'd prefer to be able to choose where the futures are completed but it "worked".

Basically, I need something like select_all but I need it to take a stream, not an iterator, because I don't have a bounded number of futures. I'll write up a full report (and maybe implement it) after turning in my thesis...

from futures-rs.

orthecreedence avatar orthecreedence commented on June 12, 2024

@alexcrichton I've updated futures-rs in my project and am now seeing that .forget() has been removed, but what is it replaced with? I removed all the .forget() calls in my project, but now I'm getting

warning: unused result which must be used: futures do nothing unless polled, #[warn(unused_must_use)] on by default

in all the places it was removed. How do I actually drive futures forward now? I've looked into executors and tasks in the docs, but I can't find an obvious way to run a future chain.

from futures-rs.

orthecreedence avatar orthecreedence commented on June 12, 2024

Oh, actually I see in some places you do

let future = ...;
thread::spawn(move || {
    future.wait();
});

However this seems to run the future chain on the new thread, not the thread the future is created on. Is there a way to execute a future equivalent to what .forget() used to? Thanks!

EDIT: Nevermind, see #332

from futures-rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.