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

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