Skip to content

Latest commit

 

History

History
executable file
·
67 lines (58 loc) · 1.41 KB

README.md

File metadata and controls

executable file
·
67 lines (58 loc) · 1.41 KB

atomic

PkgGoDev Build Status codecov Go Report Card 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

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.