1
0
mirror of https://github.com/golang/go synced 2024-11-25 02:17:57 -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) var threadLimit = make(chan struct{}, 500)
func acquireThread() { func init() {
for i := 0; i < cap(threadLimit); i++ {
threadLimit <- struct{}{} threadLimit <- struct{}{}
}
}
func acquireThread() {
<-threadLimit
} }
func releaseThread() { func releaseThread() {
<-threadLimit threadLimit <- struct{}{}
} }