Description
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version
)?
1.9
I would like to have the Condition variable to have a TimedWait
method just like pthread_cond_timedwait
so that the goroutine can suspend only for a given period of time.
I noticed that in the docs https://golang.org/pkg/sync/#Cond mention something Unlike in other systems, Wait cannot return unless awoken by Broadcast or Signal
Is this intentional?
I ask because I try to implement a blocking Queue and I'm using Cond to notify when the queue has an empty Slot to put items or when it has new items to read. It makes sense sometimes to wait for some time instead of until a signal arrives as I want to handle things gracefully. Currently, I'm trying to use a big for-select-case loop
but it gets really messy.
I understand that its a very specific case. For me, it's nice to have that, but for some others, it might be not.
Thoughts?