Commit b3fd434a authored by Robert Daniel Kortschak's avatar Robert Daniel Kortschak Committed by Rob Pike

net: make channel-based semaphore depend on receive, not send

R=r, dvyukov
CC=golang-dev
https://golang.org/cl/13348045
parent 27f4166e
......@@ -442,10 +442,16 @@ func (d *deadline) setTime(t time.Time) {
var threadLimit = make(chan struct{}, 500)
func init() {
for i := 0; i < cap(threadLimit); i++ {
threadLimit <- struct{}{}
}
}
func acquireThread() {
threadLimit <- struct{}{}
<-threadLimit
}
func releaseThread() {
<-threadLimit
threadLimit <- struct{}{}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment