Question

Is it recommended to extend the functionality of core.async with my own asynchronous functions?

The asynchrony of channels is handled by put! and take! which accept callbacks, but the protocols are nested in the async.impl.protocols namespace. Does impl mean stay out! in this case, or is it okay to implement them?

For example, I could wrap a netty channel or a java socket as a ReadPort and a WritePort.

Was it helpful?

Solution

The intention of the core.async protocols is to serve as implementation hooks for implementing your own buffers, channels, ports, etc. They exist under impl as they are part of the implementation, not the public user API.

The team considers them to be open to change until a non-alpha version of the library is released (I have no timeframe on that). From async's release until now the protocols have not changed, however there is at this moment a breaking change in process specifically to put! and take!.

If you're willing to deal with catching changes for now, feel free to implement as you wish.

Tim B has spent quite a bit of time looking at connecting async channels to the network and it is very challenging to do while retaining the channel semantics. The recommended pattern right now for this is to use dedicated threads that talk to network I/O and communicate "at the edge" with the channels in the application (probably using put! and take!). This pattern does not require implementing the internal protocols.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top