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:
parent
27f4166e37
commit
b3fd434ae0
@ -442,10 +442,16 @@ func (d *deadline) setTime(t time.Time) {
|
|||||||
|
|
||||||
var threadLimit = make(chan struct{}, 500)
|
var threadLimit = make(chan struct{}, 500)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
for i := 0; i < cap(threadLimit); i++ {
|
||||||
|
threadLimit <- struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func acquireThread() {
|
func acquireThread() {
|
||||||
threadLimit <- struct{}{}
|
<-threadLimit
|
||||||
}
|
}
|
||||||
|
|
||||||
func releaseThread() {
|
func releaseThread() {
|
||||||
<-threadLimit
|
threadLimit <- struct{}{}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user