Can the select fire while there are other goroutines still waiting on the channel?
Sure it can. Select is not different from normal chan receives. And
the other goroutine may not even get to "val = <-ch" chan receive.
What are you trying to do?
>Already solved at: http://golang.org/doc/effective_go.html#leaky_buffer
> What I was trying to do:
> Use the channel as a resource pool (connections).
> If the channel is not full, create resources on demand.
> If the channel is full, subsequent requests should wait.
--
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...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Hi Sugu,Are you trying to create a hard limit on the number of resources that may exist in your system at any given time? E.g. in case of network connections to have only N connections up simultaneously?If so, what you could do is create a buffered channel with N elements, with your producer inserting some -any- random stuff in there, the point of which is only to block it when N is reached. Whenever a resource is done (i.e. connection is handled and dropped), you remove one element from the channel and the producer(s) can continue.Like this: http://play.golang.org/p/qDAd3ERZmY
Ok, now I understood how you imagined the pool to work. But where does the signal broadcasting come into the picture with the resource pool? If all resources are put back in, and Get checks validity creating new ones if needed? Are you aiming at signalling the pool when a resource goes down so the pool can recreate before somebody requests the stale old version?