Giter VIP home page Giter VIP logo

Comments (2)

dcoutts avatar dcoutts commented on May 27, 2024

Correct me if I'm wrong but this is exactly the same behaviour as you'll get with hPutStr for String. Try it with long enough strings, or go look at the impl, it also releases the Handle lock. In fact, last time I checked the Handle code, it goes to quite some lengths to make sure that it is not evaluating arbitrary user thunks while it is holding the Handle lock.

In other words, this would be the expected behaviour. Given that evaluating the next chunk can take arbitrary time, releasing the handle lock and allowing interleaving seems like the right thing to do. Are there compelling reasons we'd want to change that?

If you really want to write multiple streams to one Handle concurrently without any coordination, you can at least control the chunk boundaries. But I'd suggest the better approach is to use your own MVar in your app. Then you're also responsible for making sure the lock is released if one of the writers goes off and sleeps while evaluating the next chunk.

from bytestring.

nmattia avatar nmattia commented on May 27, 2024

I get your point. The one reason I can come up with for changing the behavior is "it is closer to what the strict hPut does". I think I ended up going for an MVar, which is probably the easiest solution. I opened #82 which documents the current behavior. I think it can be useful. No hard feelings if you decline or reword it.

from bytestring.

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.