https://github.com/hlts2/lock-free
Simple lock-free library written in golang
https://github.com/hlts2/lock-free
go golang golang-library goroutine goroutine-safe hlts2 library lock-free threadsafe
Last synced: 11 months ago
JSON representation
Simple lock-free library written in golang
- Host: GitHub
- URL: https://github.com/hlts2/lock-free
- Owner: hlts2
- License: mit
- Created: 2018-07-18T12:11:22.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-28T11:20:45.000Z (over 7 years ago)
- Last Synced: 2025-01-20T08:09:30.840Z (about 1 year ago)
- Topics: go, golang, golang-library, goroutine, goroutine-safe, hlts2, library, lock-free, threadsafe
- Language: Go
- Homepage:
- Size: 8.79 KB
- Stars: 2
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lock-free
lock-free is simple fastest lock-free library based on [cas](https://en.wikipedia.org/wiki/Compare-and-swap) written in golang.
## Requirement
Go (>=1.8)
## Installation
```shell
go get github.com/hlts2/lock-free
```
## Example
```go
wg := new(sync.WaitGroup)
lf := lockfree.New()
for i := 0; i < size; i++ {
wg.Add(1)
go func(i int) {
defer wg.Done()
// In the block between Wait and Signal, it becomes gruoute-safe
lf.Wait()
cnt++
lf.Signal()
}(i)
}
wg.Wait()
```
## Author
[hlts2](https://github.com/hlts2)
## LICENSE
lock-free released under MIT license, refer [LICENSE](https://github.com/hlts2/lock-free/blob/master/LICENSE) file.