Skip to content

Go synchronisation primitives that support context.Context.

License

Notifications You must be signed in to change notification settings

JensRantil/go-sync

Repository files navigation

Build Status Go Report Card GoDoc

sync with Context

This is a small Golang library that tries to mimic (unless otherwise stated in doc) the behaviour of

  • sync.Mutex
  • sync.Cond

but adds context.Context to support deadlines.

So far very little time has been spent on performance here, but here are some crude benchmarks:

goos: darwin
goarch: amd64
pkg: github.com/JensRantil/sync-with-context
BenchmarkMutexLockUnlock-8              	25858257	        43.2 ns/op
BenchmarkStandardMutexLockUnlock-8      	122055702	         9.81 ns/op
BenchmarkMutexLockWithContextUnlock-8   	26493699	        43.7 ns/op
PASS
ok  	github.com/JensRantil/sync-with-context	4.665s

That is the sync.Mutex in standard library is about 77% faster than this mutex.

Credits

Initial development was sponsored by Tink.

About

Go synchronisation primitives that support context.Context.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages