Documentation ¶
Overview ¶
Package semaphore provides semaphore implementations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrOpMismatch is returned when you call Release before Acquire, // or Release after Acquire failed. ErrOpMismatch = errors.New("operation mismatch: Release called without a successful Acquire") )
Functions ¶
This section is empty.
Types ¶
type Semaphore ¶
type Semaphore struct {
// contains filtered or unexported fields
}
Semaphore is a semaphore.
type TokenizedSemaphore ¶
type TokenizedSemaphore struct {
// contains filtered or unexported fields
}
TokenizedSemaphore is a kind of semaphore which only allow the same token acquire once until it released.
func NewTokenizedSemaphore ¶
func NewTokenizedSemaphore(limit int) *TokenizedSemaphore
NewTokenizedSemaphore creates a new TokenizedSemaphore.
func (*TokenizedSemaphore) Acquire ¶
func (s *TokenizedSemaphore) Acquire(ctx context.Context, token string) error
Acquire acquires a semaphore with given token.
func (*TokenizedSemaphore) Release ¶
func (s *TokenizedSemaphore) Release(token string) error
Release releases a semaphore with given token.
Click to show internal directories.
Click to hide internal directories.