Fork me on GitHub
#core-async
<
2017-08-02
>
yenda08:08:11

if I have an unbuffered chan with two producers trying to put what happens ? which one will deliver first ?

isaac12:08:54

@yenda The order same with your put! order

tbaldridge13:08:16

@yenda that is undefined

tbaldridge13:08:50

The contract is simply that one of them will deliver, but if you have 10 puts pending, and one taker, it's undefined which will complete first. Normally it's the first put!, but "first" is a very complicated subject when dealing with multithreaded code.

joshjones14:08:40

as @tbaldridge explained some time ago on this subject, the main reason for this is that the pending puts and takes are implemented via a callback system. So when you do (>!! ..., it simply does a put! with a callback that delivers the value as a delivered promise. So, it's not as simple as "here's a data structure that has the pending puts, get the first one" -- when asynchrony is involved, ordering guarantees can be hard 😉 @yenda