Hacker News new | ask | show | jobs
by ryanbrush 4655 days ago
Understanding that core.async is new and evolving, but is there a reference or an idiomatic way to work with blocking operations, beyond the general advice of separate threads as an exercise for the reader?

EDIT: I bring this up because this seems like a common misstep for users of core.async, and a simple pattern for blocking IO might help people avoid it.

core.async really looks awesome...if we can create simple patterns for working with blocking operations, it would be a compelling model for a lot of use cases.

(Also, hats off to the core.async developers; it seems like the reward for creating something great is just demand for more. ;)

3 comments

It's true that out of the box core.async is MUCH nicer to use with existing asynchronous IO APIs. My limited experience has shown that you'll want to wrap your synchronous IO operations to play well with core.async. This generally means queueing work in an operation-local (or subsystem-local) threadpool and providing an async API for interfacing with via core.async.

The next step is deciding on how to expose the asynchronicity. I chose to accept / return channels rather than callbacks, because... well... wrapping your sync code in a callback-based async API just to glue them together with go blocks and channels seemed backward to me. :)

I think this "next level up" from the foundation of core.async has potential for some really great solutions and I'm dying to see what Tim and others will come up with...

I'm working on that right now, but it won't be out till the end of the year. I'm giving a talk at Clojure/Conj about core.async and hope to cover most of these sort of questions. I'd publish notes about it now, but that'd kind of kill my talk in two months.
Sounds great. I'm glad to know something like that's in progress, and many thanks for your efforts on this project!
https://github.com/clojure/core.async/blob/master/examples/w... seems to be the only "documentation" I've found.