atomic

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2022 License: Apache-2.0 Imports: 6 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bool

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

func (*Bool) CompareAndSwap

func (x *Bool) CompareAndSwap(old, new bool) (swapped bool)

CompareAndSwap wrapper for atomic.CompareAndSwapUint32.

func (*Bool) Load

func (x *Bool) Load() (val bool)

Load wrapper for atomic.LoadUint32.

func (*Bool) MarshalJSON added in v1.1.2

func (x *Bool) MarshalJSON() ([]byte, error)

func (*Bool) Store

func (x *Bool) Store(val bool)

Store wrapper for atomic.StoreUint32.

func (*Bool) Swap

func (x *Bool) Swap(new bool) (old bool)

Swap wrapper for atomic.SwapUint32.

type Duration

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

func (*Duration) Add

func (x *Duration) Add(delta time.Duration) time.Duration

Add wrapper for atomic.AddInt64.

func (*Duration) CompareAndSwap

func (x *Duration) CompareAndSwap(old, new time.Duration) bool

CompareAndSwap wrapper for atomic.CompareAndSwapInt64.

func (*Duration) Load

func (x *Duration) Load() time.Duration

Load wrapper for atomic.LoadInt64.

func (*Duration) MarshalJSON added in v1.1.2

func (x *Duration) MarshalJSON() ([]byte, error)

func (*Duration) Store

func (x *Duration) Store(val time.Duration)

Store wrapper for atomic.StoreInt64.

func (*Duration) Swap

func (x *Duration) Swap(new time.Duration) time.Duration

Swap wrapper for atomic.SwapInt64.

type Float32

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

func (*Float32) Add

func (x *Float32) Add(delta float32) (new float32)

Add wrapper for atomic.AddUint32.

func (*Float32) CompareAndSwap

func (x *Float32) CompareAndSwap(old, new float32) (swapped bool)

CompareAndSwap wrapper for atomic.CompareAndSwapUint32.

func (*Float32) Load

func (x *Float32) Load() (val float32)

Load wrapper for atomic.LoadUint32.

func (*Float32) MarshalJSON added in v1.1.2

func (x *Float32) MarshalJSON() ([]byte, error)

func (*Float32) Store

func (x *Float32) Store(val float32)

Store wrapper for atomic.StoreUint32.

func (*Float32) Swap

func (x *Float32) Swap(new float32) (old float32)

Swap wrapper for atomic.SwapUint32.

type Float64

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

func (*Float64) Add

func (x *Float64) Add(delta float64) (new float64)

Add wrapper for atomic.AddUint64.

func (*Float64) CompareAndSwap

func (x *Float64) CompareAndSwap(old, new float64) (swapped bool)

CompareAndSwap wrapper for atomic.CompareAndSwapUint64.

func (*Float64) Load

func (x *Float64) Load() (val float64)

Load wrapper for atomic.LoadUint64.

func (*Float64) MarshalJSON added in v1.1.2

func (x *Float64) MarshalJSON() ([]byte, error)

func (*Float64) Store

func (x *Float64) Store(val float64)

Store wrapper for atomic.StoreUint64.

func (*Float64) Swap

func (x *Float64) Swap(new float64) (old float64)

Swap wrapper for atomic.SwapUint64.

type Int32

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

func (*Int32) Add

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

Add wrapper for atomic.AddInt32.

func (*Int32) CompareAndSwap

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

CompareAndSwap wrapper for atomic.CompareAndSwapInt32.

func (*Int32) Load

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

Load wrapper for atomic.LoadInt32.

func (*Int32) MarshalJSON added in v1.1.2

func (x *Int32) MarshalJSON() ([]byte, error)

func (*Int32) Store

func (x *Int32) Store(val int32)

Store wrapper for atomic.StoreInt32.

func (*Int32) Swap

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

Swap wrapper for atomic.SwapInt32.

type Int64

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

func (*Int64) Add

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

Add wrapper for atomic.AddInt64.

func (*Int64) CompareAndSwap

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

CompareAndSwap wrapper for atomic.CompareAndSwapInt64.

func (*Int64) Load

func (x *Int64) Load() int64

Load wrapper for atomic.LoadInt64.

func (*Int64) MarshalJSON added in v1.1.2

func (x *Int64) MarshalJSON() ([]byte, error)

func (*Int64) Store

func (x *Int64) Store(val int64)

Store wrapper for atomic.StoreInt64.

func (*Int64) Swap

func (x *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 (*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 String added in v1.1.2

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

func (*String) Load added in v1.1.2

func (x *String) Load() string

Load wrapper for atomic.LoadInt64.

func (*String) MarshalJSON added in v1.1.2

func (x *String) MarshalJSON() ([]byte, error)

func (*String) Store added in v1.1.2

func (x *String) Store(val string)

Store wrapper for atomic.StoreInt64.

type Time

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

func (*Time) Load

func (x *Time) Load() time.Time

func (*Time) MarshalJSON added in v1.1.2

func (x *Time) MarshalJSON() ([]byte, error)

func (*Time) Store

func (x *Time) Store(val time.Time)

type Uint32

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

func (*Uint32) Add

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

Add wrapper for atomic.AddUint32.

func (*Uint32) CompareAndSwap

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

CompareAndSwap wrapper for atomic.CompareAndSwapUint32.

func (*Uint32) Load

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

Load wrapper for atomic.LoadUint32.

func (*Uint32) MarshalJSON added in v1.1.2

func (x *Uint32) MarshalJSON() ([]byte, error)

func (*Uint32) Store

func (x *Uint32) Store(val uint32)

Store wrapper for atomic.StoreUint32.

func (*Uint32) Swap

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

Swap wrapper for atomic.SwapUint32.

type Uint64

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

func (*Uint64) Add

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

Add wrapper for atomic.AddUint64.

func (*Uint64) CompareAndSwap

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

CompareAndSwap wrapper for atomic.CompareAndSwapUint64.

func (*Uint64) Load

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

Load wrapper for atomic.LoadUint64.

func (*Uint64) MarshalJSON added in v1.1.2

func (x *Uint64) MarshalJSON() ([]byte, error)

func (*Uint64) Store

func (x *Uint64) Store(val uint64)

Store wrapper for atomic.StoreUint64.

func (*Uint64) Swap

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

Swap wrapper for atomic.SwapUint64.

type Uintptr

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

func (*Uintptr) Add

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

Add wrapper for atomic.AddUintptr.

func (*Uintptr) CompareAndSwap

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

CompareAndSwap wrapper for atomic.CompareAndSwapUintptr.

func (*Uintptr) Load

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

Load wrapper for atomic.LoadUintptr.

func (*Uintptr) Store

func (x *Uintptr) Store(val uintptr)

Store wrapper for atomic.StoreUintptr.

func (*Uintptr) Swap

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

Swap wrapper for atomic.SwapUintptr.

type Value

type Value struct {
	atomic.Value
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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