On Sun, May 5, 2019 at 9:56 PM Louki Sumirniy
<louki.sumirniy.stal...@gmail.com> wrote:
>
> I think the key thing is the Add function I have written is not concurrent 
> safe. I didn't intend it to be as I only had the use case of a single thread 
> managing a worker pool, and I am pretty sure it is fine for this and for 
> larger pools it has lower overhead of memory *and* processing.
>
> I have revised it so the 'we are started' clause also ensures the channel is 
> in the open and operational state as well, and the channel is closed if it is 
> open, which will, yes, cause a panic if the Add function is called 
> concurrently, which enforces the contract I specify.
>
> It does not cover all of the cases like sync.WaitGroup, but it covers the 
> biggest use case, with a lot less code (no imports at all)
>
> https://play.golang.org/p/FwdKAVnNMk-

It now deadlocks: https://play.golang.org/p/HMoapELANd7

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to