gtype

package
v1.16.6 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: MIT Imports: 8 Imported by: 65

Documentation

Overview

Package gtype provides kinds of high performance and concurrent-safe basic variable types.

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 is a struct for concurrent-safe operation for type bool.

func NewBool

func NewBool(value ...bool) *Bool

NewBool creates and returns a concurrent-safe object for bool type, with given initial value <value>.

func (*Bool) Cas

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

Cas executes the compare-and-swap operation for value.

func (*Bool) Clone

func (v *Bool) Clone() *Bool

Clone clones and returns a new concurrent-safe object for bool type.

func (*Bool) MarshalJSON added in v1.9.7

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

MarshalJSON implements the interface MarshalJSON for json.Marshal.

func (*Bool) Set

func (v *Bool) Set(value bool) (old bool)

Set atomically stores <value> into t.value and returns the previous value of t.value.

func (*Bool) String added in v1.9.7

func (v *Bool) String() string

String implements String interface for string printing.

func (*Bool) UnmarshalJSON added in v1.9.7

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

UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.

func (*Bool) UnmarshalValue added in v1.11.5

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

UnmarshalValue is an interface implement which sets any type of value for <v>.

func (*Bool) Val

func (v *Bool) Val() bool

Val atomically loads and returns t.valueue.

type Byte

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

Byte is a struct for concurrent-safe operation for type byte.

func NewByte

func NewByte(value ...byte) *Byte

NewByte creates and returns a concurrent-safe object for byte type, with given initial value <value>.

func (*Byte) Add

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

Add atomically adds <delta> to t.value and returns the new value.

func (*Byte) Cas

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

Cas executes the compare-and-swap operation for value.

func (*Byte) Clone

func (v *Byte) Clone() *Byte

Clone clones and returns a new concurrent-safe object for byte type.

func (*Byte) MarshalJSON added in v1.9.7

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

MarshalJSON implements the interface MarshalJSON for json.Marshal.

func (*Byte) Set

func (v *Byte) Set(value byte) (old byte)

Set atomically stores <value> into t.value and returns the previous value of t.value.

func (*Byte) String added in v1.9.7

func (v *Byte) String() string

String implements String interface for string printing.

func (*Byte) UnmarshalJSON added in v1.9.7

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

UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.

func (*Byte) UnmarshalValue added in v1.11.5

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

UnmarshalValue is an interface implement which sets any type of value for <v>.

func (*Byte) Val

func (v *Byte) Val() byte

Val atomically loads and returns t.value.

type Bytes

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

Bytes is a struct for concurrent-safe operation for type []byte.

func NewBytes

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

NewBytes creates and returns a concurrent-safe object for []byte type, with given initial value <value>.

func (*Bytes) Clone

func (v *Bytes) Clone() *Bytes

Clone clones and returns a new concurrent-safe object for []byte type.

func (*Bytes) MarshalJSON added in v1.9.7

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

MarshalJSON implements the interface MarshalJSON for json.Marshal.

func (*Bytes) Set

func (v *Bytes) Set(value []byte) (old []byte)

Set atomically stores <value> into t.value and returns the previous value of t.value. Note: The parameter <value> cannot be nil.

func (*Bytes) String added in v1.9.7

func (v *Bytes) String() string

String implements String interface for string printing.

func (*Bytes) UnmarshalJSON added in v1.9.7

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

UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.

func (*Bytes) UnmarshalValue added in v1.11.5

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

UnmarshalValue is an interface implement which sets any type of value for <v>.

func (*Bytes) Val

func (v *Bytes) Val() []byte

Val atomically loads and returns t.value.

type Float32

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

Float32 is a struct for concurrent-safe operation for type float32.

func NewFloat32

func NewFloat32(value ...float32) *Float32

NewFloat32 creates and returns a concurrent-safe object for float32 type, with given initial value <value>.

func (*Float32) Add

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

Add atomically adds <delta> to t.value and returns the new value.

func (*Float32) Cas

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

Cas executes the compare-and-swap operation for value.

func (*Float32) Clone

func (v *Float32) Clone() *Float32

Clone clones and returns a new concurrent-safe object for float32 type.

func (*Float32) MarshalJSON added in v1.9.7

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

MarshalJSON implements the interface MarshalJSON for json.Marshal.

func (*Float32) Set

func (v *Float32) Set(value float32) (old float32)

Set atomically stores <value> into t.value and returns the previous value of t.value.

func (*Float32) String added in v1.9.7

func (v *Float32) String() string

String implements String interface for string printing.

func (*Float32) UnmarshalJSON added in v1.9.7

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

UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.

func (*Float32) UnmarshalValue added in v1.11.5

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

UnmarshalValue is an interface implement which sets any type of value for <v>.

func (*Float32) Val

func (v *Float32) Val() float32

Val atomically loads and returns t.value.

type Float64

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

Float64 is a struct for concurrent-safe operation for type float64.

func NewFloat64

func NewFloat64(value ...float64) *Float64

NewFloat64 creates and returns a concurrent-safe object for float64 type, with given initial value <value>.

func (*Float64) Add

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

Add atomically adds <delta> to t.value and returns the new value.

func (*Float64) Cas

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

Cas executes the compare-and-swap operation for value.

func (*Float64) Clone

func (v *Float64) Clone() *Float64

Clone clones and returns a new concurrent-safe object for float64 type.

func (*Float64) MarshalJSON added in v1.9.7

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

MarshalJSON implements the interface MarshalJSON for json.Marshal.

func (*Float64) Set

func (v *Float64) Set(value float64) (old float64)

Set atomically stores <value> into t.value and returns the previous value of t.value.

func (*Float64) String added in v1.9.7

func (v *Float64) String() string

String implements String interface for string printing.

func (*Float64) UnmarshalJSON added in v1.9.7

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

UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.

func (*Float64) UnmarshalValue added in v1.11.5

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

UnmarshalValue is an interface implement which sets any type of value for <v>.

func (*Float64) Val

func (v *Float64) Val() float64

Val atomically loads and returns t.value.

type Int

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

Int is a struct for concurrent-safe operation for type int.

func NewInt

func NewInt(value ...int) *Int

NewInt creates and returns a concurrent-safe object for int type, with given initial value <value>.

func (*Int) Add

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

Add atomically adds <delta> to t.value and returns the new value.

func (*Int) Cas

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

Cas executes the compare-and-swap operation for value.

func (*Int) Clone

func (v *Int) Clone() *Int

Clone clones and returns a new concurrent-safe object for int type.

func (*Int) MarshalJSON added in v1.9.7

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

MarshalJSON implements the interface MarshalJSON for json.Marshal.

func (*Int) Set

func (v *Int) Set(value int) (old int)

Set atomically stores <value> into t.value and returns the previous value of t.value.

func (*Int) String added in v1.9.7

func (v *Int) String() string

String implements String interface for string printing.

func (*Int) UnmarshalJSON added in v1.9.7

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

UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.

func (*Int) UnmarshalValue added in v1.11.5

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

UnmarshalValue is an interface implement which sets any type of value for <v>.

func (*Int) Val

func (v *Int) Val() int

Val atomically loads and returns t.value.

type Int32

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

Int32 is a struct for concurrent-safe operation for type int32.

func NewInt32

func NewInt32(value ...int32) *Int32

NewInt32 creates and returns a concurrent-safe object for int32 type, with given initial value <value>.

func (*Int32) Add

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

Add atomically adds <delta> to t.value and returns the new value.

func (*Int32) Cas

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

Cas executes the compare-and-swap operation for value.

func (*Int32) Clone

func (v *Int32) Clone() *Int32

Clone clones and returns a new concurrent-safe object for int32 type.

func (*Int32) MarshalJSON added in v1.9.7

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

MarshalJSON implements the interface MarshalJSON for json.Marshal.

func (*Int32) Set

func (v *Int32) Set(value int32) (old int32)

Set atomically stores <value> into t.value and returns the previous value of t.value.

func (*Int32) String added in v1.9.7

func (v *Int32) String() string

String implements String interface for string printing.

func (*Int32) UnmarshalJSON added in v1.9.7

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

UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.

func (*Int32) UnmarshalValue added in v1.11.5

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

UnmarshalValue is an interface implement which sets any type of value for <v>.

func (*Int32) Val

func (v *Int32) Val() int32

Val atomically loads and returns t.value.

type Int64

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

Int64 is a struct for concurrent-safe operation for type int64.

func NewInt64

func NewInt64(value ...int64) *Int64

NewInt64 creates and returns a concurrent-safe object for int64 type, with given initial value <value>.

func (*Int64) Add

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

Add atomically adds <delta> to t.value and returns the new value.

func (*Int64) Cas

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

Cas executes the compare-and-swap operation for value.

func (*Int64) Clone

func (v *Int64) Clone() *Int64

Clone clones and returns a new concurrent-safe object for int64 type.

func (*Int64) MarshalJSON added in v1.9.7

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

MarshalJSON implements the interface MarshalJSON for json.Marshal.

func (*Int64) Set

func (v *Int64) Set(value int64) (old int64)

Set atomically stores <value> into t.value and returns the previous value of t.value.

func (*Int64) String added in v1.9.7

func (v *Int64) String() string

String implements String interface for string printing.

func (*Int64) UnmarshalJSON added in v1.9.7

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

UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.

func (*Int64) UnmarshalValue added in v1.11.5

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

UnmarshalValue is an interface implement which sets any type of value for <v>.

func (*Int64) Val

func (v *Int64) Val() int64

Val atomically loads and returns t.value.

type Interface

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

Interface is a struct for concurrent-safe operation for type interface{}.

func NewInterface

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

NewInterface creates and returns a concurrent-safe object for interface{} type, with given initial value <value>.

func (*Interface) Clone

func (v *Interface) Clone() *Interface

Clone clones and returns a new concurrent-safe object for interface{} type.

func (*Interface) MarshalJSON added in v1.9.7

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

MarshalJSON implements the interface MarshalJSON for json.Marshal.

func (*Interface) Set

func (v *Interface) Set(value interface{}) (old interface{})

Set atomically stores <value> into t.value and returns the previous value of t.value. Note: The parameter <value> cannot be nil.

func (*Interface) String added in v1.9.7

func (v *Interface) String() string

String implements String interface for string printing.

func (*Interface) UnmarshalJSON added in v1.9.7

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

UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.

func (*Interface) UnmarshalValue added in v1.11.5

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

UnmarshalValue is an interface implement which sets any type of value for <v>.

func (*Interface) Val

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

Val atomically loads and returns t.value.

type String

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

String is a struct for concurrent-safe operation for type string.

func NewString

func NewString(value ...string) *String

NewString creates and returns a concurrent-safe object for string type, with given initial value <value>.

func (*String) Clone

func (v *String) Clone() *String

Clone clones and returns a new concurrent-safe object for string type.

func (*String) MarshalJSON added in v1.9.7

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

MarshalJSON implements the interface MarshalJSON for json.Marshal.

func (*String) Set

func (v *String) Set(value string) (old string)

Set atomically stores <value> into t.value and returns the previous value of t.value.

func (*String) String added in v1.9.7

func (v *String) String() string

String implements String interface for string printing.

func (*String) UnmarshalJSON added in v1.9.7

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

UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.

func (*String) UnmarshalValue added in v1.11.5

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

UnmarshalValue is an interface implement which sets any type of value for <v>.

func (*String) Val

func (v *String) Val() string

Val atomically loads and returns t.value.

type Type

type Type = Interface

Type is alias of Interface.

func New

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

New is alias of NewInterface. See NewInterface.

type Uint

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

Uint is a struct for concurrent-safe operation for type uint.

func NewUint

func NewUint(value ...uint) *Uint

NewUint creates and returns a concurrent-safe object for uint type, with given initial value <value>.

func (*Uint) Add

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

Add atomically adds <delta> to t.value and returns the new value.

func (*Uint) Cas

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

Cas executes the compare-and-swap operation for value.

func (*Uint) Clone

func (v *Uint) Clone() *Uint

Clone clones and returns a new concurrent-safe object for uint type.

func (*Uint) MarshalJSON added in v1.9.7

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

MarshalJSON implements the interface MarshalJSON for json.Marshal.

func (*Uint) Set

func (v *Uint) Set(value uint) (old uint)

Set atomically stores <value> into t.value and returns the previous value of t.value.

func (*Uint) String added in v1.9.7

func (v *Uint) String() string

String implements String interface for string printing.

func (*Uint) UnmarshalJSON added in v1.9.7

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

UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.

func (*Uint) UnmarshalValue added in v1.11.5

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

UnmarshalValue is an interface implement which sets any type of value for <v>.

func (*Uint) Val

func (v *Uint) Val() uint

Val atomically loads and returns t.value.

type Uint32

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

Uint32 is a struct for concurrent-safe operation for type uint32.

func NewUint32

func NewUint32(value ...uint32) *Uint32

NewUint32 creates and returns a concurrent-safe object for uint32 type, with given initial value <value>.

func (*Uint32) Add

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

Add atomically adds <delta> to t.value and returns the new value.

func (*Uint32) Cas

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

Cas executes the compare-and-swap operation for value.

func (*Uint32) Clone

func (v *Uint32) Clone() *Uint32

Clone clones and returns a new concurrent-safe object for uint32 type.

func (*Uint32) MarshalJSON added in v1.9.7

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

MarshalJSON implements the interface MarshalJSON for json.Marshal.

func (*Uint32) Set

func (v *Uint32) Set(value uint32) (old uint32)

Set atomically stores <value> into t.value and returns the previous value of t.value.

func (*Uint32) String added in v1.9.7

func (v *Uint32) String() string

String implements String interface for string printing.

func (*Uint32) UnmarshalJSON added in v1.9.7

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

UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.

func (*Uint32) UnmarshalValue added in v1.11.5

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

UnmarshalValue is an interface implement which sets any type of value for <v>.

func (*Uint32) Val

func (v *Uint32) Val() uint32

Val atomically loads and returns t.value.

type Uint64

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

Uint64 is a struct for concurrent-safe operation for type uint64.

func NewUint64

func NewUint64(value ...uint64) *Uint64

NewUint64 creates and returns a concurrent-safe object for uint64 type, with given initial value <value>.

func (*Uint64) Add

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

Add atomically adds <delta> to t.value and returns the new value.

func (*Uint64) Cas

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

Cas executes the compare-and-swap operation for value.

func (*Uint64) Clone

func (v *Uint64) Clone() *Uint64

Clone clones and returns a new concurrent-safe object for uint64 type.

func (*Uint64) MarshalJSON added in v1.9.7

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

MarshalJSON implements the interface MarshalJSON for json.Marshal.

func (*Uint64) Set

func (v *Uint64) Set(value uint64) (old uint64)

Set atomically stores <value> into t.value and returns the previous value of t.value.

func (*Uint64) String added in v1.9.7

func (v *Uint64) String() string

String implements String interface for string printing.

func (*Uint64) UnmarshalJSON added in v1.9.7

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

UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.

func (*Uint64) UnmarshalValue added in v1.11.5

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

UnmarshalValue is an interface implement which sets any type of value for <v>.

func (*Uint64) Val

func (v *Uint64) Val() uint64

Val atomically loads and returns t.value.

Jump to

Keyboard shortcuts

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