atomic

package
v1.1.0-rc3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

README

atomic

封装标准库 atomic 包的操作函数。

Install

go get github.com/go-spring/spring-base@v1.1.0-rc2 

Import

import "github.com/go-spring/spring-base/atomic"

Example

var i64 atomic.Int64
i64.Add(1)
i64.Store(2)
_ = i64.Load()

Documentation

Overview

Package atomic 封装标准库 atomic 包的操作函数。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Int32

type Int32 struct {
	// contains filtered or unexported fields
}

func NewInt32

func NewInt32(val int32) *Int32

func (*Int32) Add

func (i *Int32) Add(delta int32) (new int32)

Add wrapper for atomic.AddInt32.

func (*Int32) CompareAndSwap

func (i *Int32) CompareAndSwap(old, new int32) (swapped bool)

CompareAndSwap wrapper for atomic.CompareAndSwapInt32.

func (*Int32) Load

func (i *Int32) Load() (val int32)

Load wrapper for atomic.LoadInt32.

func (*Int32) Store

func (i *Int32) Store(val int32)

Store wrapper for atomic.StoreInt32.

func (*Int32) Swap

func (i *Int32) Swap(new int32) (old int32)

Swap wrapper for atomic.SwapInt32.

type Int64

type Int64 struct {
	// contains filtered or unexported fields
}

func NewInt64

func NewInt64(val int64) *Int64

func (*Int64) Add

func (i *Int64) Add(delta int64) int64

Add wrapper for atomic.AddInt64.

func (*Int64) CompareAndSwap

func (i *Int64) CompareAndSwap(old, new int64) bool

CompareAndSwap wrapper for atomic.CompareAndSwapInt64.

func (*Int64) Load

func (i *Int64) Load() int64

Load wrapper for atomic.LoadInt64.

func (*Int64) Store

func (i *Int64) Store(val int64)

Store wrapper for atomic.StoreInt64.

func (*Int64) Swap

func (i *Int64) Swap(new int64) int64

Swap wrapper for atomic.SwapInt64.

type Pointer added in v1.1.2

type Pointer struct {
	// contains filtered or unexported fields
}

func NewPointer

func NewPointer(val unsafe.Pointer) *Pointer

func (*Pointer) CompareAndSwap added in v1.1.2

func (p *Pointer) CompareAndSwap(old, new unsafe.Pointer) (swapped bool)

CompareAndSwap wrapper for atomic.CompareAndSwapPointer.

func (*Pointer) Load added in v1.1.2

func (p *Pointer) Load() (val unsafe.Pointer)

Load wrapper for atomic.LoadPointer.

func (*Pointer) Store added in v1.1.2

func (p *Pointer) Store(val unsafe.Pointer)

Store wrapper for atomic.StorePointer.

func (*Pointer) Swap added in v1.1.2

func (p *Pointer) Swap(new unsafe.Pointer) (old unsafe.Pointer)

Swap wrapper for atomic.SwapPointer.

type Uint32

type Uint32 struct {
	// contains filtered or unexported fields
}

func NewUint32

func NewUint32(val uint32) *Uint32

func (*Uint32) Add

func (u *Uint32) Add(delta uint32) (new uint32)

Add wrapper for atomic.AddUint32.

func (*Uint32) CompareAndSwap

func (u *Uint32) CompareAndSwap(old, new uint32) (swapped bool)

CompareAndSwap wrapper for atomic.CompareAndSwapUint32.

func (*Uint32) Load

func (u *Uint32) Load() (val uint32)

Load wrapper for atomic.LoadUint32.

func (*Uint32) Store

func (u *Uint32) Store(val uint32)

Store wrapper for atomic.StoreUint32.

func (*Uint32) Swap

func (u *Uint32) Swap(new uint32) (old uint32)

Swap wrapper for atomic.SwapUint32.

type Uint64

type Uint64 struct {
	// contains filtered or unexported fields
}

func NewUint64

func NewUint64(val uint64) *Uint64

func (*Uint64) Add

func (u *Uint64) Add(delta uint64) (new uint64)

Add wrapper for atomic.AddUint64.

func (*Uint64) CompareAndSwap

func (u *Uint64) CompareAndSwap(old, new uint64) (swapped bool)

CompareAndSwap wrapper for atomic.CompareAndSwapUint64.

func (*Uint64) Load

func (u *Uint64) Load() (val uint64)

Load wrapper for atomic.LoadUint64.

func (*Uint64) Store

func (u *Uint64) Store(val uint64)

Store wrapper for atomic.StoreUint64.

func (*Uint64) Swap

func (u *Uint64) Swap(new uint64) (old uint64)

Swap wrapper for atomic.SwapUint64.

type Uintptr

type Uintptr struct {
	// contains filtered or unexported fields
}

func NewUintptr

func NewUintptr(val uintptr) *Uintptr

func (*Uintptr) Add

func (u *Uintptr) Add(delta uintptr) (new uintptr)

Add wrapper for atomic.AddUintptr.

func (*Uintptr) CompareAndSwap

func (u *Uintptr) CompareAndSwap(old, new uintptr) (swapped bool)

CompareAndSwap wrapper for atomic.CompareAndSwapUintptr.

func (*Uintptr) Load

func (u *Uintptr) Load() (val uintptr)

Load wrapper for atomic.LoadUintptr.

func (*Uintptr) Store

func (u *Uintptr) Store(val uintptr)

Store wrapper for atomic.StoreUintptr.

func (*Uintptr) Swap

func (u *Uintptr) Swap(new uintptr) (old uintptr)

Swap wrapper for atomic.SwapUintptr.

type Value

type Value = atomic.Value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL