1
0
mirror of https://github.com/golang/go synced 2024-11-25 00:17:58 -07:00

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

R=r, dvyukov
CC=golang-dev
https://golang.org/cl/13348045
This commit is contained in:
Robert Daniel Kortschak 2013-08-29 17:14:57 +10:00 committed by Rob Pike
parent 27f4166e37
commit b3fd434ae0

View File

@ -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{}{}
}