All Projects → sasha-s → go-csync

sasha-s / go-csync

Licence: other
Golang: contex-aware synchronization primitives (mutex).

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to go-csync

context-mirror
Mirror of ConTeXt beta source code
Stars: ✭ 49 (+81.48%)
Mutual labels:  context
react-combine-contexts
🚀Use multiple React Contexts without pain.
Stars: ✭ 23 (-14.81%)
Mutual labels:  context
react-generate-context
A helper function for reducing React Context boilerplate
Stars: ✭ 24 (-11.11%)
Mutual labels:  context
xMenuTools
Extended context menu tools for Windows
Stars: ✭ 56 (+107.41%)
Mutual labels:  context
joincontext
Join contexts like never before!
Stars: ✭ 19 (-29.63%)
Mutual labels:  context
react-context-global-store
A simple global store based on React context
Stars: ✭ 22 (-18.52%)
Mutual labels:  context
rocket-pipes
Powerful pipes for TypeScript, that chain Promise and ADT for you 🚌 -> ⛰️ -> 🚠 -> 🏂 -> 🚀
Stars: ✭ 18 (-33.33%)
Mutual labels:  context
go-lock
go-lock is a lock library implementing read-write mutex and read-write trylock without starvation
Stars: ✭ 78 (+188.89%)
Mutual labels:  mutex
karma-go
Everything has a reason.
Stars: ✭ 15 (-44.44%)
Mutual labels:  context
contextual
🌈 Generate your Ecto contexts using this macro and eliminate boilerplate
Stars: ✭ 18 (-33.33%)
Mutual labels:  context
kubeswitch
visually select kubernetes context/namespace from tree
Stars: ✭ 15 (-44.44%)
Mutual labels:  context
react-context-tabs
Flexible tabs for React
Stars: ✭ 31 (+14.81%)
Mutual labels:  context
ctx
🍭Ctx (Context) 是一个服务模块化上下文框架。
Stars: ✭ 38 (+40.74%)
Mutual labels:  context
wc-context
Context for Web Components
Stars: ✭ 26 (-3.7%)
Mutual labels:  context
node-red-contrib-FIWARE official
FIWARE-Node-Red integration supporting NGSI-LD
Stars: ✭ 14 (-48.15%)
Mutual labels:  context
nestjs-cls
A continuation-local storage (async context) module compatible with NestJS's dependency injection.
Stars: ✭ 110 (+307.41%)
Mutual labels:  context
mutexsafe
MutexSafe will help you use mutex more effectively. Different mutex for different components are presented. In addition, you can add your own lockers and use within the library.
Stars: ✭ 15 (-44.44%)
Mutual labels:  mutex
laravel-react-spa
A Laravel-React SPA starter project template.
Stars: ✭ 94 (+248.15%)
Mutual labels:  context
multi-ctx
Multiple Spring Contexts Showcase
Stars: ✭ 16 (-40.74%)
Mutual labels:  context
semaphore
Wrapping sync.Mutex for familiar semaphore api
Stars: ✭ 39 (+44.44%)
Mutual labels:  mutex

go-csync

Golang: context-aware synchronization primitives.

Only has a mutex right now.

csync.Mutex can used as a drop-in replacement for the sync.Mutex, or with a context, like this:

var mu csync.Mutex
...
func (...) {
	ctx, cf := context.WithTimeout(context.Background(), time.Second)
	if mu.CLock(ctx) != nil {
		// Failed to lock.
		return err
	}
	defer mu.Unlock()
	// Do stuff.
}

Benchstat

On my MacBook Pro:

Comparing regular mutex to this implementation: Note, this benchmarks the Lock function.

name                old time/op  new time/op  delta
MutexUncontended-8  3.73ns ± 0%  4.43ns ±10%  +18.90%  (p=0.016 n=4+5)
Mutex-8             96.8ns ± 2%  38.6ns ±14%  -60.10%  (p=0.008 n=5+5)
MutexSlack-8         125ns ± 3%    45ns ±14%  -64.12%  (p=0.008 n=5+5)
MutexWork-8          113ns ± 3%   105ns ± 8%     ~     (p=0.095 n=5+5)
MutexWorkSlack-8     149ns ± 7%   103ns ± 5%  -30.97%  (p=0.008 n=5+5)
MutexNoSpin-8        258ns ±10%   281ns ± 7%     ~     (p=0.111 n=5+5)
MutexSpin-8         1.23µs ± 9%  1.25µs ± 5%     ~     (p=1.000 n=5+5)

Clock benchmarks: Note, this benchmars CLock function. Slightly worse than Lock.

CMutexUncontended-8         5.59ns ± 9%
CMutexUncontendedTimeout-8  5.38ns ±10%
CMutex-8                    45.1ns ± 6%
CMutexSlack-8               48.8ns ± 6%
CMutexWork-8                 110ns ± 5%
CMutexWorkSlack-8            107ns ± 7%
CMutexNoSpin-8               301ns ±19%
CMutexSpin-8                1.25µs ± 9%
CMutexTimeout-8             26.9ns ± 6%
CMutexSlackTimeout-8        44.2ns ± 3%
CMutexWorkTimeout-8          109ns ± 6%
CMutexWorkSlackTimeout-8     109ns ± 5%
CMutexNoSpinTimeout-8        294ns ± 8%
CMutexSpinTimeout-8         1.30µs ±11%
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].