https://github.com/smallnest/syncx
more advanced sync primitives in Go
https://github.com/smallnest/syncx
primitives sync
Last synced: 29 days ago
JSON representation
more advanced sync primitives in Go
- Host: GitHub
- URL: https://github.com/smallnest/syncx
- Owner: smallnest
- License: apache-2.0
- Created: 2020-02-24T06:30:19.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-28T09:21:33.000Z (about 5 years ago)
- Last Synced: 2025-03-19T06:42:47.616Z (about 1 month ago)
- Topics: primitives, sync
- Language: Go
- Homepage:
- Size: 16.6 KB
- Stars: 14
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# syncx
[](https://opensource.org/licenses/Apache-2.0) [](http://godoc.org/github.com/smallnest/syncx) [](https://travis-ci.org/smallnest/syncx) [](https://goreportcard.com/report/github.com/smallnest/syncx) [](https://coveralls.io/github/smallnest/syncx?branch=master)
More Advanced sync primitives.
Implemented some Go sync primitives.
## Token
provides token implementation.
Only the one thats owns the `Token` can do stuff and then it can handoffs the token to others.
## Batch
provides batch implementation.
It is like `errgroup` and can return all errors results of each task.
## Any
provides partial batch implementation.
You can wait some tasks have finished and returns.
## Stentor
provides pub-sub(observer) pattern.
## Examples
use **syncx** to solve [leetcode concurrency problems](https://leetcode.com/problemset/concurrency/)
- [1115 Print FooBar Alternately](https://leetcode.com/problems/print-foobar-alternately): [solution](https://github.com/smallnest/leetcode/tree/master/1115_print_foobar_alternately)
- [1116 Print Zero Even Odd](https://leetcode.com/problems/print-zero-even-odd): [solution](https://github.com/smallnest/leetcode/tree/master/1116_print_zero_even_odd)
- [1195 Fizz Buzz Multithreaded](https://leetcode.com/problems/fizz-buzz-multithreaded): [solution](https://github.com/smallnest/leetcode/tree/master/1195_fizz_buzz_multithreaded)
## Other advanced sync primitives- [singleflight](https://github.com/golang/sync/tree/master/singleflight): provides a duplicate function call suppression
- [errgroup](https://github.com/golang/sync/blob/master/errgroup/errgroup.go): provides synchronization, error propagation, and Context cancelation for groups of goroutines working on subtasks of a common task
- [semaphore](https://github.com/golang/sync/tree/master/semaphore): provides a weighted semaphore implementation