[#8] limiting: Make SemaphoreLimiter.Acquire() zero-alloc
All checks were successful
DCO action / DCO (pull_request) Successful in 29s
Vulncheck / Vulncheck (pull_request) Successful in 44s
Tests and linters / Run gofumpt (pull_request) Successful in 48s
Tests and linters / Staticcheck (pull_request) Successful in 50s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m23s
Tests and linters / Lint (pull_request) Successful in 1m24s
Tests and linters / gopls check (pull_request) Successful in 1m20s
Tests and linters / Tests (pull_request) Successful in 1m29s
Tests and linters / Tests with -race (pull_request) Successful in 1m46s
Vulncheck / Vulncheck (push) Successful in 35s
Tests and linters / Tests with -race (push) Successful in 56s
Tests and linters / Tests (push) Successful in 1m12s
Pre-commit hooks / Pre-commit (push) Successful in 1m15s
Tests and linters / Lint (push) Successful in 1m23s
Tests and linters / Run gofumpt (push) Successful in 1m17s
Tests and linters / Staticcheck (push) Successful in 1m27s
Tests and linters / gopls check (push) Successful in 1m42s
All checks were successful
DCO action / DCO (pull_request) Successful in 29s
Vulncheck / Vulncheck (pull_request) Successful in 44s
Tests and linters / Run gofumpt (pull_request) Successful in 48s
Tests and linters / Staticcheck (pull_request) Successful in 50s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m23s
Tests and linters / Lint (pull_request) Successful in 1m24s
Tests and linters / gopls check (pull_request) Successful in 1m20s
Tests and linters / Tests (pull_request) Successful in 1m29s
Tests and linters / Tests with -race (pull_request) Successful in 1m46s
Vulncheck / Vulncheck (push) Successful in 35s
Tests and linters / Tests with -race (push) Successful in 56s
Tests and linters / Tests (push) Successful in 1m12s
Pre-commit hooks / Pre-commit (push) Successful in 1m15s
Tests and linters / Lint (push) Successful in 1m23s
Tests and linters / Run gofumpt (push) Successful in 1m17s
Tests and linters / Staticcheck (push) Successful in 1m27s
Tests and linters / gopls check (push) Successful in 1m42s
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 {
|
||||
return func() { sem.Release() }, true
|
||||
return sem.Release, true
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue