forked from TrueCloudLab/frostfs-qos
[#8] limiting: Make SemaphoreLimiter.Acquire() zero-alloc
Previously, `Acquire` on exising key did 1 allocation because `func() { sem.Release() }` was a closure capturing different variables. Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
356851eed3
commit
cafa869fea
1 changed files with 1 additions and 1 deletions
|
@ -69,7 +69,7 @@ func (lr *SemaphoreLimiter) Acquire(key string) (ReleaseFunc, bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ok := sem.Acquire(); ok {
|
if ok := sem.Acquire(); ok {
|
||||||
return func() { sem.Release() }, true
|
return sem.Release, true
|
||||||
}
|
}
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue