https://github.com/hslam/atomic
Package atomic provides low-level atomic memory primitives useful for implementing synchronization algorithms.
https://github.com/hslam/atomic
add atomic bool bytes cas compare-and-swap go golang string swap
Last synced: about 1 year ago
JSON representation
Package atomic provides low-level atomic memory primitives useful for implementing synchronization algorithms.
- Host: GitHub
- URL: https://github.com/hslam/atomic
- Owner: hslam
- License: mit
- Created: 2020-10-07T09:06:54.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-01-16T19:16:09.000Z (over 5 years ago)
- Last Synced: 2023-07-27T18:04:44.468Z (over 2 years ago)
- Topics: add, atomic, bool, bytes, cas, compare-and-swap, go, golang, string, swap
- Language: Go
- Homepage:
- Size: 90.8 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# atomic
[](https://pkg.go.dev/github.com/hslam/atomic)
[](https://github.com/hslam/atomic/actions)
[](https://codecov.io/gh/hslam/atomic)
[](https://goreportcard.com/report/github.com/hslam/atomic)
[](https://github.com/hslam/atomic/blob/master/LICENSE)
Package atomic provides low-level atomic memory primitives useful for implementing synchronization algorithms.
## Feature
* Int8
* Int16
* Int32
* Int64
* Uint8
* Uint16
* Uint32
* Uint64
* Uintptr
* Pointer
* Float32
* Float64
* Bool
* String
* Bytes
* Value
## Get started
### Install
```
go get github.com/hslam/atomic
```
### Import
```
import "github.com/hslam/atomic"
```
### Usage
#### Example
```go
package main
import (
"fmt"
"github.com/hslam/atomic"
)
func main() {
str := atomic.NewString("")
str.Store("Hi")
str.Swap("Hello")
str.Add(" atomic")
str.CompareAndSwap("Hello atomic", "Hello World")
fmt.Println(str.Load())
}
```
### Output
```
Hello World
```
### License
This package is licensed under a MIT license (Copyright (c) 2020 Meng Huang)
### Author
atomic was written by Meng Huang.