Skip to content
/ sema Public

Multiple Binary/Counting/Count+Timeout semaphore implementations in Go.

License

Notifications You must be signed in to change notification settings

tarndt/sema

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sema: Semaphores for Go

License: MPL 2.0Go Reference Go Report Card

Author & Version

Author: Tylor Arndt 0.95 RC - API may change. (Bug reports and PRs are welcome)

Features

Semaphore variants provided are:

  • Binary semaphores
  • Counting semaphores
  • Counting semaphores with timeout support
  • Context support was recently added

All written in pure Go.

Implementations

Previously there was a sync.Cond based implemenation that was removed with Go runtime performance improvements rendered it overly complex for a small performance gain over the channel-based implemenation.

Getting Started

In sema.go you will find the three default constructors and related core interfaces.

	func NewSemaphore() Semaphore {...}
	func NewCountingSema(count uint) CountingSema {...}
	func NewTimeoutSema(count uint, defaultTimeout time.Duration) TimeoutCountingSema {...}

The Semaphore interface is extended from being binary to counting by CountingSema which in turn is enhanced with time-out support in its TimeoutCountingSema variant.

About

Multiple Binary/Counting/Count+Timeout semaphore implementations in Go.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages