Skip to content
/ xsync Public

Priortizable and cancellable synchronization primitives in Go.

License

Notifications You must be signed in to change notification settings

gobwas/xsync

Repository files navigation

xsync

GoDoc Travis

Priortizable and cancellable synchronization primitives in Go.

Usage

xsync.WorkerGroup

packagemain

import(
"sync"

"github /gobwas/xsync"
)

funcmain() {
varwgxsync.WorkerGroup
wg.Exec(
xsync.Demand{
Priority:xsync.BytePriority(42),
},
xsync.TaskFunc(func(ctx*xsync.WorkerContext) {

}),
})
wg.Close()
}

xsync.Cond

packagemain

import(
"sync"

"github /gobwas/xsync"
)

funcmain() {
varmusync.Mutex
cond:=xsync.Cond{
L:&mu,
}
mu.Lock()
for!condition{
cond.Wait(xsync.Demand{
Priority:xsync.BytePriority(42),
})
}
// action on condition.
mu.Unlock()
}

examples

For more examples please take a look intoexamplesfolder.

Why?

The idea of this package appeared year ago or something when I was playing with high-performant concurrent programming. The main intention of the package is to provide an ability to select which kind of task should be performed when execution resources are limited.

Status

This package is one of those projects that might be developed but then not then released anywhen. Fortunately I found time and motivation to complete it and share with the community.

Current API is not fixed, thus there is nov1.0.0tag yet. My main concerns are related to theDemandinterface which I don't like much. Maybe I will change it over time.

Performance

Goroutine blocking mechanics are built over channels. Thus, it can't be more efficient than standard libarary'ssyncpackage. There are few benchmarks in tests, so feel free to run them.

About

Priortizable and cancellable synchronization primitives in Go.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published