Skip to content

Commit 53a50b7

Browse files
committed
Use custom type for worker token
1 parent b118399 commit 53a50b7

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

msgpackrpc/connection.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,11 @@ type Connection struct {
5353
activeOutRequestsMutex sync.Mutex
5454
lastOutRequestsIndex atomic.Uint32
5555

56-
workerSlots chan bool
56+
workerSlots chan token
5757
}
5858

59+
type token struct{}
60+
5961
type inRequest struct {
6062
cancel func()
6163
}
@@ -118,7 +120,7 @@ func NewConnectionWithMaxWorkers(in io.ReadCloser, out io.WriteCloser, requestHa
118120
logger: NullLogger{},
119121
}
120122
if maxWorkers > 0 {
121-
conn.workerSlots = make(chan bool, maxWorkers)
123+
conn.workerSlots = make(chan token, maxWorkers)
122124
}
123125
return conn
124126
}
@@ -128,7 +130,7 @@ func (c *Connection) startWorker(cb func()) {
128130
go cb()
129131
return
130132
}
131-
c.workerSlots <- true
133+
c.workerSlots <- token{}
132134
go func() {
133135
defer func() { <-c.workerSlots }()
134136
cb()

0 commit comments

Comments
 (0)