semaphore

package
v0.0.0-...-c12452b Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: GPL-3.0 Imports: 1 Imported by: 11

Documentation

Overview

Package semaphore contains an implementation of a counting semaphore.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Semaphore

type Semaphore struct {
	C chan struct{}
	// contains filtered or unexported fields
}

Semaphore is a counting semaphore. It must be initialized before use.

func NewSemaphore

func NewSemaphore(size int) *Semaphore

NewSemaphore creates a new semaphore.

func (*Semaphore) Close

func (obj *Semaphore) Close()

Close shuts down the semaphore and releases all the locks.

func (*Semaphore) Init

func (obj *Semaphore) Init(size int)

Init initializes the semaphore.

func (*Semaphore) P

func (obj *Semaphore) P(n int) error

P acquires n resources.

func (*Semaphore) V

func (obj *Semaphore) V(n int) error

V releases n resources.

Jump to

Keyboard shortcuts

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