fabric: github.com/hyperledger/fabric/common/semaphore Index | Files

package semaphore

import "github.com/hyperledger/fabric/common/semaphore"

Package semaphore provides an implementation of a counting semaphore.


Package Files


type Semaphore Uses

type Semaphore chan struct{}

Semaphore is a buffered channel based implementation of a counting semaphore.

func New Uses

func New(permits int) Semaphore

New creates a Semaphore with the specified number of permits.

func (Semaphore) Acquire Uses

func (s Semaphore) Acquire(ctx context.Context) error

Acquire acquires a permit. This call will block until a permit is available or the provided context is completed.

If the provided context is completed, the method will return the cancellation error.

func (Semaphore) Release Uses

func (s Semaphore) Release()

Release releases a permit.

func (Semaphore) TryAcquire Uses

func (s Semaphore) TryAcquire() bool

TryAcquire acquires the semaphore without blocking. Returns true if the semaphore is acquired. Otherwise, returns false and leaves the semaphore unchanged.

Package semaphore imports 1 packages (graph) and is imported by 4 packages. Updated 2020-07-28. Refresh now. Tools for package owners.