odf / ceci-channels

Blocking channels for the Ceci library
MIT License
7 stars 1 forks source link

Documentation for multicast #1

Open pedroteixeira opened 10 years ago

pedroteixeira commented 10 years ago

Hi, Could you add some doc to the multicast function?

From the code, it seems it will pushes to taps in sequence (potentially blocking if a tap is not pulling).

Would you recommend another approach for pushing to multiple channels (asynchronously) all messages that comes to a single source channel?

thanks

odf commented 10 years ago

Sorry for the missing documentation. The multicast function and maybe some things in util.js are still pretty experimental. But I'll have a look over them.

Multicast was inspired by mult in core.async, so the blocking is intentional. I just realised I'm not doing the pushing in parallel, though, which I probably should.

One can always write to a channel asynchronously by leaving off the yield, but I don't know if that's a good idea. Like the core.async documentation says, it's probably better to use buffers on slow taps.

pedroteixeira commented 10 years ago

Thanks for the link. I'll ensure buffered channels are used as taps for now.

That's what I thought, that perhaps pushing to multi should spawn multiple functions to push to each tap in parallel. But it does seem like it could be an option of the Multicast if waits for all pushes at every item pushed to source, don't know what drawbacks that could have.

odf commented 10 years ago

I'm reopening this as a reminder that I still need to write that documentation.