Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Start cleaning up Supply design/implementation.
This commit substantially refactors how supplies work on the inside, along with a couple of API changes to deal with design issues. Supply is now much more like Seq, in that it's a container around a large number of implementations. Those implementations now do the Tappable role. Tapping a Supply still returns a Tap, but now it only has a .close method. A Supply no longer has a list of taps; it's just something that can be tapped. This allows for far cleaner and more efficient implementation of the Supply combinators. More importantly, it removes the design issues that rogue code could in theory take any Supply and emit values into it. Creating an on-demand Supply is now the role of a separate class, at present called Publisher, name subject to review. A Publisher has a Supply method to obtain a Supply. The Supply can be tapped many times, and the Publisher used to emit/done/quit to all those tappers (thus making it the typical way to do live supplies). Code can therefore expose a Supply, but keep the right to publish values to itself, which will be more robust. The on meta-combinator is gone, in favor of using supply blocks. Some of the built-in combinators using on have been rewritten in terms of Supply blocks. A number remain to be refactored. Finally, the notion of serial and sane supplies has been introduced. A serial supply promises it'll never emit more than one value at a time. A sane supply promises it'll follow the Supply protocol, that is [emit* [done|quit]], and in addition implies serial. All of the built-in combinators provide sanity; Publisher also enforces this, but does provide an escape hatch just in case. This simplifies the implementation of many combinators, and will also help prevent a number of situations that existed before where it was all too easy to write code using supplies that had data races. supplies writing data races into their code.
- Loading branch information