semaphore

package module
v0.0.0-...-ef89761 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2014 License: BSD-3-Clause Imports: 0 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

semaphore

A Go semaphore primitive

Documentation

Overview

A simple semaphore primitive

Usage:

sem := New(3)
for i := 0; i < 10; i++ {
	sem.Wait()
	go func() {
		time.Sleep(time.Second)
		sem.Signal()
	}()
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Semaphore

type Semaphore chan struct{}

func New

func New(size int) Semaphore

New returns an instance of a `Semaphore`:

sem := New(10)

func (Semaphore) Signal

func (s Semaphore) Signal()

Increments the `Semaphore` by 1

func (Semaphore) Wait

func (s Semaphore) Wait()

Decrements the `Semaphore` by 1

Jump to

Keyboard shortcuts

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