Description
In Singularity channels have the useful property that sending never allocates and never blocks. This should allow for a very simple implementation that our semantics don't.
There are some additional enabling properties (or limitations):
- Each channel has one sender and one receiver
- Each channel has a defined protocol (channel contract) that must be obeyed
Based on the contract they statically know the maximum number of elements that any queue will hold so they always allocate exactly the right amount. The contract is verified dynamically.
Adopting Singularity-style channels has two potential benefits:
First, contracts on their own are a useful thing, particularly in a language that aims to be 'safe'.
More importantly though it allows the port to use a lock-free circular buffer for the queue. Improving messaging performance is really the only reason we would want to impose more restrictions on channels. Whether this optimization will really pay off in practice I am not sure - there are several other locks on the send and receive paths.
Still not sure this is the right thing to do as it will create more barriers in channel usability, but maybe higher-level abstractions could be built on top.