semaphore

package
v3.4.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2019 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Semaphore

type Semaphore interface {
	// Acquire blocks until num resource counts have been obtained
	Acquire(num int)

	// TryAcquire attempts to obtain num resource counts without blocking
	TryAcquire(num int) bool

	// Release causes num resource counts to be released
	Release(num int)
}

Semaphore is the interface for the several types of semaphore implemented by Amass.

func NewSimpleSemaphore

func NewSimpleSemaphore(max int) Semaphore

NewSimpleSemaphore returns a SimpleSemaphore initialized to max resource counts.

func NewTimedSemaphore

func NewTimedSemaphore(max int, delay time.Duration) Semaphore

NewTimedSemaphore returns a TimedSemaphore initialized to max resource counts and delay release frequency.

type SimpleSemaphore

type SimpleSemaphore struct {
	// contains filtered or unexported fields
}

SimpleSemaphore implements a synchronization object type capable of being a counting semaphore.

func (*SimpleSemaphore) Acquire

func (s *SimpleSemaphore) Acquire(num int)

Acquire blocks until num resource counts have been obtained.

func (*SimpleSemaphore) Release

func (s *SimpleSemaphore) Release(num int)

Release causes num resource counts to be released.

func (*SimpleSemaphore) TryAcquire

func (s *SimpleSemaphore) TryAcquire(num int) bool

TryAcquire attempts to obtain num resource counts without blocking. The method returns true when successful in acquiring the resource counts.

type TimedSemaphore

type TimedSemaphore struct {
	// contains filtered or unexported fields
}

TimedSemaphore implements a synchronization object type capable of being a counting semaphore.

func (*TimedSemaphore) Acquire

func (t *TimedSemaphore) Acquire(num int)

Acquire blocks until num resource counts have been obtained.

func (*TimedSemaphore) Release

func (t *TimedSemaphore) Release(num int)

Release causes num resource counts to be released.

func (*TimedSemaphore) TryAcquire

func (t *TimedSemaphore) TryAcquire(num int) bool

TryAcquire attempts to obtain num resource counts without blocking. The method returns true when successful in acquiring the resource counts.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL