Coder Social home page Coder Social logo

purescript-aff-bus's People

Contributors

garyb avatar georgevarghese185 avatar jordanmartinez avatar kl0tl avatar kritzcreek avatar maxdeviant avatar natefaubion avatar pete-murphy avatar safareli avatar thomashoneyman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

purescript-aff-bus's Issues

Buffering of messages

I am building an analog to pipes-concurrency (purescript-pipes-aff), and I am looking for a solution to buffer messages for the producer to read from. Currently bus just gives me a single message and I have to be fast not to miss it. I am wondering what would be involved (and if this would be the right place for this) to buffer a configurable amount of messages with configurable behavior. What I like and appreciate about purescript-aff-bus is the notable absence of FFI calls, leaving that entirely to the purescript-aff library and I think the buffer implementations could and should be implemented similarly. For reference, this is how it's implemented in haskell: https://github.com/Gabriel439/Haskell-Pipes-Concurrency-Library/blob/fccb359dbfb2988da83166d4e2bc6ff01dbe986d/src/Pipes/Concurrent.hs#L177-L198. Any input would be greatly appreciated.

Memory leak in node

Hi,

noticed that Aff-Bus is leaking slowly memory in a toy project i have. Here is a minimal working example which shows the leakage quite well (on my machine after 30sec 500MB and rising):

loopy :: BusRW Unit -> Aff _ Unit
loopy bus = do
  _ <- Bus.read bus
  _ <- forkAff $ loopy bus
  Bus.write unit bus
  
main :: forall e. Eff _ Unit
main = launchAff_ $ do
  bus <- Bus.make
  _ <- forkAff $ loopy bus
  Bus.write unit bus

I have only tested this with node (v8.11.1) not in a browser.

After playing around a bit, i noticed that the problem seems to be the traverse with Either here https://github.com/slamdata/purescript-aff-bus/blob/master/src/Control/Monad/Aff/Bus.purs#L64

Replacing the traverse with pattern-matching seems to fix the problem e.g.

attempt (takeVar cell) >>= case _ of
    Left _ -> pure unit
    Right res -> do ....

Can anyone confirm the leakage? Is this even a problem in Aff-Bus or is it Aff making problems?

Repository doesn't have a quick start section in the README

Is your change request related to a problem? Please describe.
As described in the documentation section of the Library Guidelines, Contributors libraries are expected to have in their README a short summary of the library's purpose, installation instructions, a quick start with a minimal usage example, and links to the documentation and contributing guide.

This library currently doesn't have a completed quick start in the README.

Describe the solution you'd like
The library needs a quick start section after the installation instructions. argonaut-codecs is one example of a library with a quick start.

Additional context
See the Governance repository for more information about requirements in the Contributors organization.

Library doesn't have sufficient module documentation

Is your change request related to a problem? Please describe.
As described in the documentation section of the Library Guidelines, Contributors libraries are expected to have mostly complete module documentation, preferably uploaded to Pursuit.

This library currently doesn't have sufficient module documentation -- several publicly-exported types have no documentation at all.

Describe the solution you'd like
These types all need documentation:

data Cap
data Bus (r ∷ # Type) a = Bus (AVar a) (AVar (List (AVar a)))
type BusR = BusR' ()
type BusR' r = Bus (readCap | r)
type BusW = BusW' ()
type BusW' r = Bus (writeCap | r)
type BusRW = Bus (readCap, writeCap)

Once updated, we should tag a release and upload new module documentation to Pursuit so that folks can use it.

Additional context
See the Governance repository for more information about requirements in the Contributors organization.

Add a way for Bus with no `write :: Cap` to be killed.

In some cases you might wanna allow "reader" (read :: Cap) to be able to kill a bus too.

I'm thinking on something like:

  • add type BusRK = BusR' (kill :: Cap)
  • add split' ∷ ∀ a. BusRW a → Tuple (BusRK a) (BusW a).
  • changing kill ∷ ∀ eff a r. CanKill r => Exn.Error → Bus r a → Aff (avar ∷ AVAR | eff) Unit, this CanKill instance will be available for write :: Cap or kill :: Cap

Attempting to write to a bus during an existing write is ignored

test_writeInWrite   eff. Aff (Effects eff) Unit
test_writeInWrite = do
  bus ← Bus.make
  ref ← liftEff $ newRef false

  let
    proc = do
      res ← Bus.read bus
      case res of
        1Bus.write 2 bus
        2 → liftEff (writeRef ref true)
        _ → pure unit
      proc

  f ← forkAff proc

  Bus.write 1 bus

  assert =<< liftEff (readRef ref)
  killFiber (error "Done") f
  log "OK"

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.