Git Product home page Git Product logo

Comments (5)

alexcrichton avatar alexcrichton commented on May 29, 2024

I don't think these'd be too difficult to implement, but @carllerche do you have a use case in mind as well? It might be good to have one just to help designing the APIs to work with it.

from futures-rs.

carllerche avatar carllerche commented on May 29, 2024

Off the top of my head, a Task is managing a Tcp connection for a client. The client handle sends requests to the connection task using a channel. The connection errors. It would be nice for the channel that sends requests to be closed cleanly. Aka, the consuming end can drop knowing that it received all pending requests and completed them w/ an error and that the client handle will not be able to send any further requests to the dead connection.

Hope this makes sense.

from futures-rs.

jwilm avatar jwilm commented on May 29, 2024

I've run into the exact problem @carllerche describes with mpsc::channel. Atomic close and drain from the receiver side would be nice to have here.

from futures-rs.

alexcrichton avatar alexcrichton commented on May 29, 2024

Ok I think that makes sense yeah. I think this is going to need coordination/APIs on both ends. That is, the producer half will need a Result of some form to hand back the message or at least indicate that delivery failed. The production half probably just needs a try_release method of some form then that attempts to shut down the channel but fails if there's items in flight.

I think for stream::channel we have a vector to return the item with a result, but for oneshot we do not. This can likely be solved by just returning a result from complete, akin to SendError in mpsc

from futures-rs.

alexcrichton avatar alexcrichton commented on May 29, 2024

added to channel in #245

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.