安全变量类

package
v0.0.0-...-2910145 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package gtype 提供高性能且并发安全的基本变量类型。

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
}

Bool 是一个结构体,用于对 bool 类型进行并发安全操作。

func NewBool

func NewBool(value ...bool) *Bool

NewBool 创建并返回一个用于 bool 类型的并发安全对象, 初始值为给定的 `value`。

func (*Bool) Cas

func (v *Bool) Cas(old, new bool) (swapped bool)

Cas 执行值的比较并交换操作。

func (*Bool) Clone

func (v *Bool) Clone() *Bool

Clone 克隆并返回一个用于布尔类型的新的线程安全对象。

func (*Bool) DeepCopy

func (v *Bool) DeepCopy() interface{}

DeepCopy 实现接口,用于当前类型的深度复制。

func (Bool) MarshalJSON

func (v Bool) MarshalJSON() ([]byte, error)

MarshalJSON 实现了 json.Marshal 接口所需的 MarshalJSON 方法。

func (*Bool) String

func (v *Bool) String() string

String 实现了 String 接口以便进行字符串打印。

func (*Bool) UnmarshalJSON

func (v *Bool) UnmarshalJSON(b []byte) error

UnmarshalJSON 实现了 json.Unmarshal 接口的 UnmarshalJSON 方法。

func (*Bool) UnmarshalValue

func (v *Bool) UnmarshalValue(value interface{}) error

UnmarshalValue 是一个接口实现,用于为 `v` 设置任意类型的值。

func (*Bool) X取值

func (v *Bool) X取值() bool

Val 原子性地加载并返回 t.value。

func (*Bool) X设置值

func (v *Bool) X设置值(value bool) (old bool)

Set 方法通过原子操作将`value`存储到t.value中,并返回修改前的t.value的值。

type Byte

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

Byte 是一个结构体,用于对 byte 类型进行并发安全操作。

func NewByte

func NewByte(value ...byte) *Byte

NewByte创建并返回一个用于byte类型的并发安全对象, 其初始值为给定的`value`。

func (*Byte) Add

func (v *Byte) Add(delta byte) (new byte)

Add 原子性地将 `delta` 加到 t.value 上,并返回新的值。

func (*Byte) Cas

func (v *Byte) Cas(old, new byte) (swapped bool)

Cas 执行值的比较并交换操作。

func (*Byte) Clone

func (v *Byte) Clone() *Byte

Clone 克隆并返回一个新的适用于 byte 类型的并发安全对象副本。

func (*Byte) DeepCopy

func (v *Byte) DeepCopy() interface{}

DeepCopy 实现接口,用于当前类型的深度复制。

func (Byte) MarshalJSON

func (v Byte) MarshalJSON() ([]byte, error)

MarshalJSON 实现了 json.Marshal 接口所需的 MarshalJSON 方法。

func (*Byte) String

func (v *Byte) String() string

String 实现了 String 接口以便进行字符串打印。

func (*Byte) UnmarshalJSON

func (v *Byte) UnmarshalJSON(b []byte) error

UnmarshalJSON 实现了 json.Unmarshal 接口的 UnmarshalJSON 方法。

func (*Byte) UnmarshalValue

func (v *Byte) UnmarshalValue(value interface{}) error

UnmarshalValue 是一个接口实现,用于为 `v` 设置任意类型的值。

func (*Byte) X取值

func (v *Byte) X取值() byte

Val 原子性地加载并返回 t.value。

func (*Byte) X设置值

func (v *Byte) X设置值(value byte) (old byte)

Set 方法通过原子操作将`value`存储到t.value中,并返回修改前的t.value的值。

type Bytes

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

Bytes 是一个结构体,用于对 []byte 类型进行并发安全操作。

func NewBytes

func NewBytes(value ...[]byte) *Bytes

NewBytes 创建并返回一个对 []byte 类型安全的并发对象, 其初始值为给定的 `value`。

func (*Bytes) Clone

func (v *Bytes) Clone() *Bytes

Clone 克隆并返回一个新的 []byte 类型的浅复制对象。

func (*Bytes) DeepCopy

func (v *Bytes) DeepCopy() interface{}

DeepCopy 实现接口,用于当前类型的深度复制。

func (Bytes) MarshalJSON

func (v Bytes) MarshalJSON() ([]byte, error)

MarshalJSON 实现了 json.Marshal 接口所需的 MarshalJSON 方法。

func (*Bytes) String

func (v *Bytes) String() string

String 实现了 String 接口以便进行字符串打印。

func (*Bytes) UnmarshalJSON

func (v *Bytes) UnmarshalJSON(b []byte) error

UnmarshalJSON 实现了 json.Unmarshal 接口的 UnmarshalJSON 方法。

func (*Bytes) UnmarshalValue

func (v *Bytes) UnmarshalValue(value interface{}) error

UnmarshalValue 是一个接口实现,用于为 `v` 设置任意类型的值。

func (*Bytes) X取值

func (v *Bytes) X取值() []byte

Val 原子性地加载并返回 t.value。

func (*Bytes) X设置值

func (v *Bytes) X设置值(value []byte) (old []byte)

Set 方法通过原子操作将`value`存储到t.value,并返回修改前的t.value的值。 注意:参数`value`不能为空。

type Float32

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

Float32 是一个结构体,用于对 float32 类型进行并发安全操作。

func NewFloat32

func NewFloat32(value ...float32) *Float32

NewFloat32 创建并返回一个用于 float32 类型的并发安全对象, 其初始值为给定的 `value`。

func (*Float32) Add

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

Add 原子性地将 `delta` 加到 t.value 上,并返回新的值。

func (*Float32) Cas

func (v *Float32) Cas(old, new float32) (swapped bool)

Cas 执行值的比较并交换操作。

func (*Float32) Clone

func (v *Float32) Clone() *Float32

Clone 克隆并返回一个用于 float32 类型的新并发安全对象。

func (*Float32) DeepCopy

func (v *Float32) DeepCopy() interface{}

DeepCopy 实现接口,用于当前类型的深度复制。

func (Float32) MarshalJSON

func (v Float32) MarshalJSON() ([]byte, error)

MarshalJSON 实现了 json.Marshal 接口所需的 MarshalJSON 方法。

func (*Float32) String

func (v *Float32) String() string

String 实现了 String 接口以便进行字符串打印。

func (*Float32) UnmarshalJSON

func (v *Float32) UnmarshalJSON(b []byte) error

UnmarshalJSON 实现了 json.Unmarshal 接口的 UnmarshalJSON 方法。

func (*Float32) UnmarshalValue

func (v *Float32) UnmarshalValue(value interface{}) error

UnmarshalValue 是一个接口实现,用于为 `v` 设置任意类型的值。

func (*Float32) X取值

func (v *Float32) X取值() float32

Val 原子性地加载并返回 t.value。

func (*Float32) X设置值

func (v *Float32) X设置值(value float32) (old float32)

Set 方法通过原子操作将`value`存储到t.value中,并返回修改前的t.value的值。

type Float64

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

Float64 是一个结构体,用于对 float64 类型进行并发安全操作。

func NewFloat64

func NewFloat64(value ...float64) *Float64

NewFloat64 创建并返回一个用于 float64 类型的并发安全对象, 其初始值为给定的 `value`。

func (*Float64) Add

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

Add 原子性地将 `delta` 加到 t.value 上,并返回新的值。

func (*Float64) Cas

func (v *Float64) Cas(old, new float64) (swapped bool)

Cas 执行值的比较并交换操作。

func (*Float64) Clone

func (v *Float64) Clone() *Float64

Clone 克隆并返回一个用于 float64 类型的新并发安全对象。

func (*Float64) DeepCopy

func (v *Float64) DeepCopy() interface{}

DeepCopy 实现接口,用于当前类型的深度复制。

func (Float64) MarshalJSON

func (v Float64) MarshalJSON() ([]byte, error)

MarshalJSON 实现了 json.Marshal 接口所需的 MarshalJSON 方法。

func (*Float64) String

func (v *Float64) String() string

String 实现了 String 接口以便进行字符串打印。

func (*Float64) UnmarshalJSON

func (v *Float64) UnmarshalJSON(b []byte) error

UnmarshalJSON 实现了 json.Unmarshal 接口的 UnmarshalJSON 方法。

func (*Float64) UnmarshalValue

func (v *Float64) UnmarshalValue(value interface{}) error

UnmarshalValue 是一个接口实现,用于为 `v` 设置任意类型的值。

func (*Float64) X取值

func (v *Float64) X取值() float64

Val 原子性地加载并返回 t.value。

func (*Float64) X设置值

func (v *Float64) X设置值(value float64) (old float64)

Set 方法通过原子操作将`value`存储到t.value中,并返回修改前的t.value的值。

type Int

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

Int 是一个结构体,用于对 int 类型进行并发安全操作。

func NewInt

func NewInt(value ...int) *Int

NewInt 创建并返回一个用于 int 类型的并发安全对象, 其初始值为给定的 `value`。

func (*Int) Add

func (v *Int) Add(delta int) (new int)

Add 原子性地将 `delta` 加到 t.value 上,并返回新的值。

func (*Int) Cas

func (v *Int) Cas(old, new int) (swapped bool)

Cas 执行值的比较并交换操作。

func (*Int) Clone

func (v *Int) Clone() *Int

Clone 克隆并返回一个新的适用于 int 类型的并发安全对象。

func (*Int) DeepCopy

func (v *Int) DeepCopy() interface{}

DeepCopy 实现接口,用于当前类型的深度复制。

func (Int) MarshalJSON

func (v Int) MarshalJSON() ([]byte, error)

MarshalJSON 实现了 json.Marshal 接口所需的 MarshalJSON 方法。

func (*Int) String

func (v *Int) String() string

String 实现了 String 接口以便进行字符串打印。

func (*Int) UnmarshalJSON

func (v *Int) UnmarshalJSON(b []byte) error

UnmarshalJSON 实现了 json.Unmarshal 接口的 UnmarshalJSON 方法。

func (*Int) UnmarshalValue

func (v *Int) UnmarshalValue(value interface{}) error

UnmarshalValue 是一个接口实现,用于为 `v` 设置任意类型的值。

func (*Int) X取值

func (v *Int) X取值() int

Val 原子性地加载并返回 t.value。

func (*Int) X设置值

func (v *Int) X设置值(value int) (old int)

Set 方法通过原子操作将`value`存储到t.value中,并返回修改前的t.value的值。

type Int32

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

Int32 是一个结构体,用于对 int32 类型进行并发安全操作。

func NewInt32

func NewInt32(value ...int32) *Int32

NewInt32 创建并返回一个适用于 int32 类型的并发安全对象, 其初始值为给定的 `value`。

func (*Int32) Add

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

Add 原子性地将 `delta` 加到 t.value 上,并返回新的值。

func (*Int32) Cas

func (v *Int32) Cas(old, new int32) (swapped bool)

Cas 执行值的比较并交换操作。

func (*Int32) Clone

func (v *Int32) Clone() *Int32

Clone 克隆并返回一个新的适用于 int32 类型的并发安全对象。

func (*Int32) DeepCopy

func (v *Int32) DeepCopy() interface{}

DeepCopy 实现接口,用于当前类型的深度复制。

func (Int32) MarshalJSON

func (v Int32) MarshalJSON() ([]byte, error)

MarshalJSON 实现了 json.Marshal 接口所需的 MarshalJSON 方法。

func (*Int32) String

func (v *Int32) String() string

String 实现了 String 接口以便进行字符串打印。

func (*Int32) UnmarshalJSON

func (v *Int32) UnmarshalJSON(b []byte) error

UnmarshalJSON 实现了 json.Unmarshal 接口的 UnmarshalJSON 方法。

func (*Int32) UnmarshalValue

func (v *Int32) UnmarshalValue(value interface{}) error

UnmarshalValue 是一个接口实现,用于为 `v` 设置任意类型的值。

func (*Int32) X取值

func (v *Int32) X取值() int32

Val 原子性地加载并返回 t.value。

func (*Int32) X设置值

func (v *Int32) X设置值(value int32) (old int32)

Set 方法通过原子操作将`value`存储到t.value中,并返回修改前的t.value的值。

type Int64

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

Int64 是一个结构体,用于对 int64 类型进行并发安全操作。

func NewInt64

func NewInt64(value ...int64) *Int64

NewInt64 创建并返回一个适用于 int64 类型的并发安全对象, 其初始值为给定的 `value`。

func (*Int64) Add

func (v *Int64) Add(delta int64) (new int64)

Add 原子性地将 `delta` 加到 t.value 上,并返回新的值。

func (*Int64) Cas

func (v *Int64) Cas(old, new int64) (swapped bool)

Cas 执行值的比较并交换操作。

func (*Int64) Clone

func (v *Int64) Clone() *Int64

Clone 克隆并返回一个用于 int64 类型的新并发安全对象。

func (*Int64) DeepCopy

func (v *Int64) DeepCopy() interface{}

DeepCopy 实现接口,用于当前类型的深度复制。

func (Int64) MarshalJSON

func (v Int64) MarshalJSON() ([]byte, error)

MarshalJSON 实现了 json.Marshal 接口所需的 MarshalJSON 方法。

func (*Int64) String

func (v *Int64) String() string

String 实现了 String 接口以便进行字符串打印。

func (*Int64) UnmarshalJSON

func (v *Int64) UnmarshalJSON(b []byte) error

UnmarshalJSON 实现了 json.Unmarshal 接口的 UnmarshalJSON 方法。

func (*Int64) UnmarshalValue

func (v *Int64) UnmarshalValue(value interface{}) error

UnmarshalValue 是一个接口实现,用于为 `v` 设置任意类型的值。

func (*Int64) X取值

func (v *Int64) X取值() int64

Val 原子性地加载并返回 t.value。

func (*Int64) X设置值

func (v *Int64) X设置值(value int64) (old int64)

Set 方法通过原子操作将`value`存储到t.value中,并返回修改前的t.value的值。

type Interface

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

Interface 是一个结构体,用于对 interface{} 类型进行并发安全操作。

func New

func New(value ...interface{}) *Interface

New 是 NewInterface 的别名。 请参阅 NewInterface。

func NewInterface

func NewInterface(value ...interface{}) *Interface

NewInterface 创建并返回一个对 interface{} 类型安全的并发对象, 其初始值为给定的 `value`。

func (*Interface) Clone

func (v *Interface) Clone() *Interface

Clone 克隆并返回一个用于 interface{} 类型的新并发安全对象。

func (*Interface) DeepCopy

func (v *Interface) DeepCopy() interface{}

DeepCopy 实现接口,用于当前类型的深度复制。

func (Interface) MarshalJSON

func (v Interface) MarshalJSON() ([]byte, error)

MarshalJSON 实现了 json.Marshal 接口所需的 MarshalJSON 方法。

func (*Interface) String

func (v *Interface) String() string

String 实现了 String 接口以便进行字符串打印。

func (*Interface) UnmarshalJSON

func (v *Interface) UnmarshalJSON(b []byte) error

UnmarshalJSON 实现了 json.Unmarshal 接口的 UnmarshalJSON 方法。

func (*Interface) UnmarshalValue

func (v *Interface) UnmarshalValue(value interface{}) error

UnmarshalValue 是一个接口实现,用于为 `v` 设置任意类型的值。

func (*Interface) X取值

func (v *Interface) X取值() interface{}

Val 原子性地加载并返回 t.value。

func (*Interface) X设置值

func (v *Interface) X设置值(value interface{}) (old interface{})

Set 方法通过原子操作将`value`存储到t.value,并返回修改前的t.value的值。 注意:参数`value`不能为空。

type String

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

String 是一个结构体,用于对字符串类型进行并发安全操作。

func NewString

func NewString(value ...string) *String

NewString 创建并返回一个用于字符串类型的安全并发对象, 其初始值为给定的 `value`。

func (*String) Clone

func (v *String) Clone() *String

Clone 克隆并返回一个用于字符串类型的新并发安全对象。

func (*String) DeepCopy

func (v *String) DeepCopy() interface{}

DeepCopy 实现接口,用于当前类型的深度复制。

func (String) MarshalJSON

func (v String) MarshalJSON() ([]byte, error)

MarshalJSON 实现了 json.Marshal 接口所需的 MarshalJSON 方法。

func (*String) String

func (v *String) String() string

String 实现了 String 接口以便进行字符串打印。

func (*String) UnmarshalJSON

func (v *String) UnmarshalJSON(b []byte) error

UnmarshalJSON 实现了 json.Unmarshal 接口的 UnmarshalJSON 方法。

func (*String) UnmarshalValue

func (v *String) UnmarshalValue(value interface{}) error

UnmarshalValue 是一个接口实现,用于为 `v` 设置任意类型的值。

func (*String) X取值

func (v *String) X取值() string

Val 原子性地加载并返回 t.value。

func (*String) X设置值

func (v *String) X设置值(value string) (old string)

Set 方法通过原子操作将`value`存储到t.value中,并返回修改前的t.value的值。

type Uint

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

Uint 是一个结构体,用于并发安全地操作 uint 类型。

func NewUint

func NewUint(value ...uint) *Uint

NewUint 创建并返回一个用于 uint 类型的并发安全对象, 其初始值为给定的 `value`。

func (*Uint) Add

func (v *Uint) Add(delta uint) (new uint)

Add 原子性地将 `delta` 加到 t.value 上,并返回新的值。

func (*Uint) Cas

func (v *Uint) Cas(old, new uint) (swapped bool)

Cas 执行值的比较并交换操作。

func (*Uint) Clone

func (v *Uint) Clone() *Uint

Clone 克隆并返回一个用于 uint 类型的新并发安全对象。

func (*Uint) DeepCopy

func (v *Uint) DeepCopy() interface{}

DeepCopy 实现接口,用于当前类型的深度复制。

func (Uint) MarshalJSON

func (v Uint) MarshalJSON() ([]byte, error)

MarshalJSON 实现了 json.Marshal 接口所需的 MarshalJSON 方法。

func (*Uint) String

func (v *Uint) String() string

String 实现了 String 接口以便进行字符串打印。

func (*Uint) UnmarshalJSON

func (v *Uint) UnmarshalJSON(b []byte) error

UnmarshalJSON 实现了 json.Unmarshal 接口的 UnmarshalJSON 方法。

func (*Uint) UnmarshalValue

func (v *Uint) UnmarshalValue(value interface{}) error

UnmarshalValue 是一个接口实现,用于为 `v` 设置任意类型的值。

func (*Uint) X取值

func (v *Uint) X取值() uint

Val 原子性地加载并返回 t.value。

func (*Uint) X设置值

func (v *Uint) X设置值(value uint) (old uint)

Set 方法通过原子操作将`value`存储到t.value中,并返回修改前的t.value的值。

type Uint32

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

Uint32 是一个结构体,用于对 uint32 类型进行并发安全操作。

func NewUint32

func NewUint32(value ...uint32) *Uint32

NewUint32 创建并返回一个适用于uint32类型的并发安全对象, 其初始值为给定的 `value`。

func (*Uint32) Add

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

Add 原子性地将 `delta` 加到 t.value 上,并返回新的值。

func (*Uint32) Cas

func (v *Uint32) Cas(old, new uint32) (swapped bool)

Cas 执行值的比较并交换操作。

func (*Uint32) Clone

func (v *Uint32) Clone() *Uint32

Clone 克隆并返回一个用于 uint32 类型的新并发安全对象。

func (*Uint32) DeepCopy

func (v *Uint32) DeepCopy() interface{}

DeepCopy 实现接口,用于当前类型的深度复制。

func (Uint32) MarshalJSON

func (v Uint32) MarshalJSON() ([]byte, error)

MarshalJSON 实现了 json.Marshal 接口所需的 MarshalJSON 方法。

func (*Uint32) String

func (v *Uint32) String() string

String 实现了 String 接口以便进行字符串打印。

func (*Uint32) UnmarshalJSON

func (v *Uint32) UnmarshalJSON(b []byte) error

UnmarshalJSON 实现了 json.Unmarshal 接口的 UnmarshalJSON 方法。

func (*Uint32) UnmarshalValue

func (v *Uint32) UnmarshalValue(value interface{}) error

UnmarshalValue 是一个接口实现,用于为 `v` 设置任意类型的值。

func (*Uint32) X取值

func (v *Uint32) X取值() uint32

Val 原子性地加载并返回 t.value。

func (*Uint32) X设置值

func (v *Uint32) X设置值(value uint32) (old uint32)

Set 方法通过原子操作将`value`存储到t.value中,并返回修改前的t.value的值。

type Uint64

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

Uint64 是一个结构体,用于对 uint64 类型进行并发安全操作。

func NewUint64

func NewUint64(value ...uint64) *Uint64

NewUint64 创建并返回一个用于 uint64 类型的并发安全对象, 其初始值为给定的 `value`。

func (*Uint64) Add

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

Add 原子性地将 `delta` 加到 t.value 上,并返回新的值。

func (*Uint64) Cas

func (v *Uint64) Cas(old, new uint64) (swapped bool)

Cas 执行值的比较并交换操作。

func (*Uint64) Clone

func (v *Uint64) Clone() *Uint64

Clone 克隆并返回一个用于 uint64 类型的新并发安全对象。

func (*Uint64) DeepCopy

func (v *Uint64) DeepCopy() interface{}

DeepCopy 实现接口,用于当前类型的深度复制。

func (Uint64) MarshalJSON

func (v Uint64) MarshalJSON() ([]byte, error)

MarshalJSON 实现了 json.Marshal 接口所需的 MarshalJSON 方法。

func (*Uint64) String

func (v *Uint64) String() string

String 实现了 String 接口以便进行字符串打印。

func (*Uint64) UnmarshalJSON

func (v *Uint64) UnmarshalJSON(b []byte) error

UnmarshalJSON 实现了 json.Unmarshal 接口的 UnmarshalJSON 方法。

func (*Uint64) UnmarshalValue

func (v *Uint64) UnmarshalValue(value interface{}) error

UnmarshalValue 是一个接口实现,用于为 `v` 设置任意类型的值。

func (*Uint64) X取值

func (v *Uint64) X取值() uint64

Val 原子性地加载并返回 t.value。

func (*Uint64) X设置值

func (v *Uint64) X设置值(value uint64) (old uint64)

Set 方法通过原子操作将`value`存储到t.value中,并返回修改前的t.value的值。

Jump to

Keyboard shortcuts

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