Files
temporal/common/locks/priority_semaphore.go
Yichao Yang 19fcc17756 Improve priority semaphore (#9286)
## What changed?
- When checking waiters, only check waiter with higher or equal
priority.
- Allow specifying priority in TryAcquire()

## Why?
- If there's all waiters have lower priority, we don't really need to
create a new waiter and later unblock it.

## How did you test it?
- [ ] built
- [ ] run locally and tested manually
- [x] covered by existing tests
- [ ] added new unit test(s)
- [ ] added new functional test(s)
2026-02-12 21:42:54 +00:00

12 lines
200 B
Go

package locks
import "context"
type (
PrioritySemaphore interface {
Acquire(ctx context.Context, priority Priority, n int) error
TryAcquire(priority Priority, n int) bool
Release(n int)
}
)