Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MultiSem ¶
type MultiSem struct {
// contains filtered or unexported fields
}
MultiSem is a semaphore that is made out of multiple underlying semaphores. The semaphores are attempted one at a time.
func (*MultiSem) Acquire ¶
Acquire acquires a semaphore. If all semaphores are starved, it only blocks on the last semaphore.
func (*MultiSem) TryAcquire ¶
func (ms *MultiSem) TryAcquire(n int64) (ReleaseFun, bool)
TryAcquire acquires a semaphore, but does not block.
type ReleaseFun ¶
type ReleaseFun func()
ReleaseFun is a function that needs to be called to release the semaphore.
type Semaphore ¶
type Semaphore interface { // Acquire acquires a resource on the semaphore. If no resource is available, // the call blocks until one is made available. Acquire(ctx context.Context, n int64) (ReleaseFun, error) // TryAcquire acquires a resource on the semaphore. If no resource is // available, the call returns immediately with false. TryAcquire(n int64) (ReleaseFun, bool) }
Semaphore is a generic semaphore.
func NewMultiSem ¶
NewMultiSem creates a new MultiSem.
func NewWeighted ¶
NewWeighted creates a new weighted semaphore.
type Weighted ¶
type Weighted struct {
// contains filtered or unexported fields
}
Weighted is a weighted semaphore.
func (*Weighted) TryAcquire ¶
func (w *Weighted) TryAcquire(n int64) (ReleaseFun, bool)
TryAcquire acquires a semaphore, but does not block.
Click to show internal directories.
Click to hide internal directories.