197
}
198
if s.size-s.cur < w.n {
200
>
// find a waiter with a smaller request), but under load that could cause
201
>
// starvation for large requests; instead, we leave all remaining waiters
202
>
// blocked. For the same reason, we should not wake lower priority waiters.
203
>
//
204
>
// Consider a semaphore used as a read-write lock, with N tokens, N
205
>
// readers, and one writer. Each reader can Acquire(1) to obtain a read
206
>
// lock. The writer can Acquire(N) to obtain a write lock, excluding all
207
>
// of the readers. If we allow the readers to jump ahead in the queue,
208
>
// the writer will starve — there is always one token available for every
209
>
// reader.
210
>
return
211
>
}
212
213
s.cur += w.n