Skip to content

kevinburke/semaphore

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

semaphore

This implements a semaphore in Go. Use this to manage the maximum amount of concurrency you want.

GoDoc

Usage

To create a new Semaphore with 5 workers:

import "github.com/kevinburke/semaphore"
...
sem := semaphore.New(5) // new semaphore with 5 permits

Acquire one of the workers:

sem.Acquire() // one
// Acquire with a timeout, or cancelable context:
sem.AcquireContext(context.TODO())

Once you're done with the semaphore:

sem.Release() // Release one worker
sem.Drain() // Release them all

Complete documentation

See here: https://godoc.org/github.com/kevinburke/semaphore

Packages

No packages published

Languages

  • Go 98.3%
  • Makefile 1.7%