semaphore

package
v1.8.10 Latest Latest
Warning

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

Go to latest
Published: May 6, 2022 License: MIT 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 struct {
	// contains filtered or unexported fields
}

Semaphore used to control access to a common resource by multiple goroutines.

func New

func New(n int) *Semaphore

New returns a new counting semaphore of length `n`.

func (*Semaphore) Len added in v0.5.5

func (s *Semaphore) Len() int

Len returns the number of goroutines currently acquired the semaphore.

func (*Semaphore) Signal

func (s *Semaphore) Signal()

Signal the semaphore. A random waiting goroutine will be waken up.

func (*Semaphore) Wait

func (s *Semaphore) Wait()

Wait for the semaphore. Blocks until the resource is available.

func (*Semaphore) Waiting

func (s *Semaphore) Waiting() int

Waiting returs the number of waiting goroutines on the semaphore.

Jump to

Keyboard shortcuts

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