Documentation ¶
Overview ¶
Package gtype provides high performance and concurrent-safe basic variable types.
Index ¶
- type Bool
- func (v *Bool) Cas(old, new bool) (swapped bool)
- func (v *Bool) Clone() *Bool
- func (v *Bool) DeepCopy() interface{}
- func (v Bool) MarshalJSON() ([]byte, error)
- func (v *Bool) Set(value bool) (old bool)
- func (v *Bool) String() string
- func (v *Bool) UnmarshalJSON(b []byte) error
- func (v *Bool) UnmarshalValue(value interface{}) error
- func (v *Bool) Val() bool
- type Byte
- func (v *Byte) Add(delta byte) (new byte)
- func (v *Byte) Cas(old, new byte) (swapped bool)
- func (v *Byte) Clone() *Byte
- func (v *Byte) DeepCopy() interface{}
- func (v Byte) MarshalJSON() ([]byte, error)
- func (v *Byte) Set(value byte) (old byte)
- func (v *Byte) String() string
- func (v *Byte) UnmarshalJSON(b []byte) error
- func (v *Byte) UnmarshalValue(value interface{}) error
- func (v *Byte) Val() byte
- type Bytes
- func (v *Bytes) Clone() *Bytes
- func (v *Bytes) DeepCopy() interface{}
- func (v Bytes) MarshalJSON() ([]byte, error)
- func (v *Bytes) Set(value []byte) (old []byte)
- func (v *Bytes) String() string
- func (v *Bytes) UnmarshalJSON(b []byte) error
- func (v *Bytes) UnmarshalValue(value interface{}) error
- func (v *Bytes) Val() []byte
- type Float32
- func (v *Float32) Add(delta float32) (new float32)
- func (v *Float32) Cas(old, new float32) (swapped bool)
- func (v *Float32) Clone() *Float32
- func (v *Float32) DeepCopy() interface{}
- func (v Float32) MarshalJSON() ([]byte, error)
- func (v *Float32) Set(value float32) (old float32)
- func (v *Float32) String() string
- func (v *Float32) UnmarshalJSON(b []byte) error
- func (v *Float32) UnmarshalValue(value interface{}) error
- func (v *Float32) Val() float32
- type Float64
- func (v *Float64) Add(delta float64) (new float64)
- func (v *Float64) Cas(old, new float64) (swapped bool)
- func (v *Float64) Clone() *Float64
- func (v *Float64) DeepCopy() interface{}
- func (v Float64) MarshalJSON() ([]byte, error)
- func (v *Float64) Set(value float64) (old float64)
- func (v *Float64) String() string
- func (v *Float64) UnmarshalJSON(b []byte) error
- func (v *Float64) UnmarshalValue(value interface{}) error
- func (v *Float64) Val() float64
- type Int
- func (v *Int) Add(delta int) (new int)
- func (v *Int) Cas(old, new int) (swapped bool)
- func (v *Int) Clone() *Int
- func (v *Int) DeepCopy() interface{}
- func (v Int) MarshalJSON() ([]byte, error)
- func (v *Int) Set(value int) (old int)
- func (v *Int) String() string
- func (v *Int) UnmarshalJSON(b []byte) error
- func (v *Int) UnmarshalValue(value interface{}) error
- func (v *Int) Val() int
- type Int32
- func (v *Int32) Add(delta int32) (new int32)
- func (v *Int32) Cas(old, new int32) (swapped bool)
- func (v *Int32) Clone() *Int32
- func (v *Int32) DeepCopy() interface{}
- func (v Int32) MarshalJSON() ([]byte, error)
- func (v *Int32) Set(value int32) (old int32)
- func (v *Int32) String() string
- func (v *Int32) UnmarshalJSON(b []byte) error
- func (v *Int32) UnmarshalValue(value interface{}) error
- func (v *Int32) Val() int32
- type Int64
- func (v *Int64) Add(delta int64) (new int64)
- func (v *Int64) Cas(old, new int64) (swapped bool)
- func (v *Int64) Clone() *Int64
- func (v *Int64) DeepCopy() interface{}
- func (v Int64) MarshalJSON() ([]byte, error)
- func (v *Int64) Set(value int64) (old int64)
- func (v *Int64) String() string
- func (v *Int64) UnmarshalJSON(b []byte) error
- func (v *Int64) UnmarshalValue(value interface{}) error
- func (v *Int64) Val() int64
- type Interface
- func (v *Interface) Clone() *Interface
- func (v *Interface) DeepCopy() interface{}
- func (v Interface) MarshalJSON() ([]byte, error)
- func (v *Interface) Set(value interface{}) (old interface{})
- func (v *Interface) String() string
- func (v *Interface) UnmarshalJSON(b []byte) error
- func (v *Interface) UnmarshalValue(value interface{}) error
- func (v *Interface) Val() interface{}
- type String
- func (v *String) Clone() *String
- func (v *String) DeepCopy() interface{}
- func (v String) MarshalJSON() ([]byte, error)
- func (v *String) Set(value string) (old string)
- func (v *String) String() string
- func (v *String) UnmarshalJSON(b []byte) error
- func (v *String) UnmarshalValue(value interface{}) error
- func (v *String) Val() string
- type Uint
- func (v *Uint) Add(delta uint) (new uint)
- func (v *Uint) Cas(old, new uint) (swapped bool)
- func (v *Uint) Clone() *Uint
- func (v *Uint) DeepCopy() interface{}
- func (v Uint) MarshalJSON() ([]byte, error)
- func (v *Uint) Set(value uint) (old uint)
- func (v *Uint) String() string
- func (v *Uint) UnmarshalJSON(b []byte) error
- func (v *Uint) UnmarshalValue(value interface{}) error
- func (v *Uint) Val() uint
- type Uint32
- func (v *Uint32) Add(delta uint32) (new uint32)
- func (v *Uint32) Cas(old, new uint32) (swapped bool)
- func (v *Uint32) Clone() *Uint32
- func (v *Uint32) DeepCopy() interface{}
- func (v Uint32) MarshalJSON() ([]byte, error)
- func (v *Uint32) Set(value uint32) (old uint32)
- func (v *Uint32) String() string
- func (v *Uint32) UnmarshalJSON(b []byte) error
- func (v *Uint32) UnmarshalValue(value interface{}) error
- func (v *Uint32) Val() uint32
- type Uint64
- func (v *Uint64) Add(delta uint64) (new uint64)
- func (v *Uint64) Cas(old, new uint64) (swapped bool)
- func (v *Uint64) Clone() *Uint64
- func (v *Uint64) DeepCopy() interface{}
- func (v Uint64) MarshalJSON() ([]byte, error)
- func (v *Uint64) Set(value uint64) (old uint64)
- func (v *Uint64) String() string
- func (v *Uint64) UnmarshalJSON(b []byte) error
- func (v *Uint64) UnmarshalValue(value interface{}) error
- func (v *Uint64) Val() uint64
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 ¶
NewBool creates and returns a concurrent-safe object for bool type, with given initial value `value`.
func (*Bool) Cas ¶
Cas executes the compare-and-swap operation for value.
func (*Bool) Clone ¶
Clone clones and returns a new concurrent-safe object for bool type.
func (*Bool) DeepCopy ¶
func (v *Bool) DeepCopy() interface{}
DeepCopy implements interface for deep copy of current type.
func (Bool) MarshalJSON ¶
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*Bool) Set ¶
Set atomically stores `value` into t.value and returns the previous value of t.value.
func (*Bool) String ¶
String implements String interface for string printing.
func (*Bool) UnmarshalJSON ¶
UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.
func (*Bool) UnmarshalValue ¶
UnmarshalValue is an interface implement which sets any type of value for `v`.
type Byte ¶
type Byte struct {
// contains filtered or unexported fields
}
Byte is a struct for concurrent-safe operation for type byte.
func NewByte ¶
NewByte creates and returns a concurrent-safe object for byte type, with given initial value `value`.
func (*Byte) Add ¶
Add atomically adds `delta` to t.value and returns the new value.
func (*Byte) Cas ¶
Cas executes the compare-and-swap operation for value.
func (*Byte) Clone ¶
Clone clones and returns a new concurrent-safe object for byte type.
func (*Byte) DeepCopy ¶
func (v *Byte) DeepCopy() interface{}
DeepCopy implements interface for deep copy of current type.
func (Byte) MarshalJSON ¶
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*Byte) Set ¶
Set atomically stores `value` into t.value and returns the previous value of t.value.
func (*Byte) String ¶
String implements String interface for string printing.
func (*Byte) UnmarshalJSON ¶
UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.
func (*Byte) UnmarshalValue ¶
UnmarshalValue is an interface implement which sets any type of value for `v`.
type Bytes ¶
type Bytes struct {
// contains filtered or unexported fields
}
Bytes is a struct for concurrent-safe operation for type []byte.
func NewBytes ¶
NewBytes creates and returns a concurrent-safe object for []byte type, with given initial value `value`.
func (*Bytes) Clone ¶
Clone clones and returns a new shallow copy object for []byte type.
func (*Bytes) DeepCopy ¶
func (v *Bytes) DeepCopy() interface{}
DeepCopy implements interface for deep copy of current type.
func (Bytes) MarshalJSON ¶
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*Bytes) Set ¶
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 ¶
String implements String interface for string printing.
func (*Bytes) UnmarshalJSON ¶
UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.
func (*Bytes) UnmarshalValue ¶
UnmarshalValue is an interface implement which sets any type of value for `v`.
type Float32 ¶
type Float32 struct {
// contains filtered or unexported fields
}
Float32 is a struct for concurrent-safe operation for type float32.
func NewFloat32 ¶
NewFloat32 creates and returns a concurrent-safe object for float32 type, with given initial value `value`.
func (*Float32) Add ¶
Add atomically adds `delta` to t.value and returns the new value.
func (*Float32) Cas ¶
Cas executes the compare-and-swap operation for value.
func (*Float32) Clone ¶
Clone clones and returns a new concurrent-safe object for float32 type.
func (*Float32) DeepCopy ¶
func (v *Float32) DeepCopy() interface{}
DeepCopy implements interface for deep copy of current type.
func (Float32) MarshalJSON ¶
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*Float32) Set ¶
Set atomically stores `value` into t.value and returns the previous value of t.value.
func (*Float32) String ¶
String implements String interface for string printing.
func (*Float32) UnmarshalJSON ¶
UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.
func (*Float32) UnmarshalValue ¶
UnmarshalValue is an interface implement which sets any type of value for `v`.
type Float64 ¶
type Float64 struct {
// contains filtered or unexported fields
}
Float64 is a struct for concurrent-safe operation for type float64.
func NewFloat64 ¶
NewFloat64 creates and returns a concurrent-safe object for float64 type, with given initial value `value`.
func (*Float64) Add ¶
Add atomically adds `delta` to t.value and returns the new value.
func (*Float64) Cas ¶
Cas executes the compare-and-swap operation for value.
func (*Float64) Clone ¶
Clone clones and returns a new concurrent-safe object for float64 type.
func (*Float64) DeepCopy ¶
func (v *Float64) DeepCopy() interface{}
DeepCopy implements interface for deep copy of current type.
func (Float64) MarshalJSON ¶
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*Float64) Set ¶
Set atomically stores `value` into t.value and returns the previous value of t.value.
func (*Float64) String ¶
String implements String interface for string printing.
func (*Float64) UnmarshalJSON ¶
UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.
func (*Float64) UnmarshalValue ¶
UnmarshalValue is an interface implement which sets any type of value for `v`.
type Int ¶
type Int struct {
// contains filtered or unexported fields
}
Int is a struct for concurrent-safe operation for type int.
func NewInt ¶
NewInt creates and returns a concurrent-safe object for int type, with given initial value `value`.
func (*Int) Add ¶
Add atomically adds `delta` to t.value and returns the new value.
func (*Int) Cas ¶
Cas executes the compare-and-swap operation for value.
func (*Int) Clone ¶
Clone clones and returns a new concurrent-safe object for int type.
func (*Int) DeepCopy ¶
func (v *Int) DeepCopy() interface{}
DeepCopy implements interface for deep copy of current type.
func (Int) MarshalJSON ¶
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*Int) Set ¶
Set atomically stores `value` into t.value and returns the previous value of t.value.
func (*Int) String ¶
String implements String interface for string printing.
func (*Int) UnmarshalJSON ¶
UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.
func (*Int) UnmarshalValue ¶
UnmarshalValue is an interface implement which sets any type of value for `v`.
type Int32 ¶
type Int32 struct {
// contains filtered or unexported fields
}
Int32 is a struct for concurrent-safe operation for type int32.
func NewInt32 ¶
NewInt32 creates and returns a concurrent-safe object for int32 type, with given initial value `value`.
func (*Int32) Add ¶
Add atomically adds `delta` to t.value and returns the new value.
func (*Int32) Cas ¶
Cas executes the compare-and-swap operation for value.
func (*Int32) Clone ¶
Clone clones and returns a new concurrent-safe object for int32 type.
func (*Int32) DeepCopy ¶
func (v *Int32) DeepCopy() interface{}
DeepCopy implements interface for deep copy of current type.
func (Int32) MarshalJSON ¶
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*Int32) Set ¶
Set atomically stores `value` into t.value and returns the previous value of t.value.
func (*Int32) String ¶
String implements String interface for string printing.
func (*Int32) UnmarshalJSON ¶
UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.
func (*Int32) UnmarshalValue ¶
UnmarshalValue is an interface implement which sets any type of value for `v`.
type Int64 ¶
type Int64 struct {
// contains filtered or unexported fields
}
Int64 is a struct for concurrent-safe operation for type int64.
func NewInt64 ¶
NewInt64 creates and returns a concurrent-safe object for int64 type, with given initial value `value`.
func (*Int64) Add ¶
Add atomically adds `delta` to t.value and returns the new value.
func (*Int64) Cas ¶
Cas executes the compare-and-swap operation for value.
func (*Int64) Clone ¶
Clone clones and returns a new concurrent-safe object for int64 type.
func (*Int64) DeepCopy ¶
func (v *Int64) DeepCopy() interface{}
DeepCopy implements interface for deep copy of current type.
func (Int64) MarshalJSON ¶
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*Int64) Set ¶
Set atomically stores `value` into t.value and returns the previous value of t.value.
func (*Int64) String ¶
String implements String interface for string printing.
func (*Int64) UnmarshalJSON ¶
UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.
func (*Int64) UnmarshalValue ¶
UnmarshalValue is an interface implement which sets any type of value for `v`.
type Interface ¶
type Interface struct {
// contains filtered or unexported fields
}
Interface is a struct for concurrent-safe operation for type interface{}.
func New ¶
func New(value ...interface{}) *Interface
New is alias of NewInterface. See NewInterface.
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 ¶
Clone clones and returns a new concurrent-safe object for interface{} type.
func (*Interface) DeepCopy ¶
func (v *Interface) DeepCopy() interface{}
DeepCopy implements interface for deep copy of current type.
func (Interface) MarshalJSON ¶
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 ¶
String implements String interface for string printing.
func (*Interface) UnmarshalJSON ¶
UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.
func (*Interface) UnmarshalValue ¶
UnmarshalValue is an interface implement which sets any type of value for `v`.
type String ¶
type String struct {
// contains filtered or unexported fields
}
String is a struct for concurrent-safe operation for type string.
func NewString ¶
NewString creates and returns a concurrent-safe object for string type, with given initial value `value`.
func (*String) Clone ¶
Clone clones and returns a new concurrent-safe object for string type.
func (*String) DeepCopy ¶
func (v *String) DeepCopy() interface{}
DeepCopy implements interface for deep copy of current type.
func (String) MarshalJSON ¶
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*String) Set ¶
Set atomically stores `value` into t.value and returns the previous value of t.value.
func (*String) String ¶
String implements String interface for string printing.
func (*String) UnmarshalJSON ¶
UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.
func (*String) UnmarshalValue ¶
UnmarshalValue is an interface implement which sets any type of value for `v`.
type Uint ¶
type Uint struct {
// contains filtered or unexported fields
}
Uint is a struct for concurrent-safe operation for type uint.
func NewUint ¶
NewUint creates and returns a concurrent-safe object for uint type, with given initial value `value`.
func (*Uint) Add ¶
Add atomically adds `delta` to t.value and returns the new value.
func (*Uint) Cas ¶
Cas executes the compare-and-swap operation for value.
func (*Uint) Clone ¶
Clone clones and returns a new concurrent-safe object for uint type.
func (*Uint) DeepCopy ¶
func (v *Uint) DeepCopy() interface{}
DeepCopy implements interface for deep copy of current type.
func (Uint) MarshalJSON ¶
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*Uint) Set ¶
Set atomically stores `value` into t.value and returns the previous value of t.value.
func (*Uint) String ¶
String implements String interface for string printing.
func (*Uint) UnmarshalJSON ¶
UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.
func (*Uint) UnmarshalValue ¶
UnmarshalValue is an interface implement which sets any type of value for `v`.
type Uint32 ¶
type Uint32 struct {
// contains filtered or unexported fields
}
Uint32 is a struct for concurrent-safe operation for type uint32.
func NewUint32 ¶
NewUint32 creates and returns a concurrent-safe object for uint32 type, with given initial value `value`.
func (*Uint32) Add ¶
Add atomically adds `delta` to t.value and returns the new value.
func (*Uint32) Cas ¶
Cas executes the compare-and-swap operation for value.
func (*Uint32) Clone ¶
Clone clones and returns a new concurrent-safe object for uint32 type.
func (*Uint32) DeepCopy ¶
func (v *Uint32) DeepCopy() interface{}
DeepCopy implements interface for deep copy of current type.
func (Uint32) MarshalJSON ¶
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*Uint32) Set ¶
Set atomically stores `value` into t.value and returns the previous value of t.value.
func (*Uint32) String ¶
String implements String interface for string printing.
func (*Uint32) UnmarshalJSON ¶
UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.
func (*Uint32) UnmarshalValue ¶
UnmarshalValue is an interface implement which sets any type of value for `v`.
type Uint64 ¶
type Uint64 struct {
// contains filtered or unexported fields
}
Uint64 is a struct for concurrent-safe operation for type uint64.
func NewUint64 ¶
NewUint64 creates and returns a concurrent-safe object for uint64 type, with given initial value `value`.
func (*Uint64) Add ¶
Add atomically adds `delta` to t.value and returns the new value.
func (*Uint64) Cas ¶
Cas executes the compare-and-swap operation for value.
func (*Uint64) Clone ¶
Clone clones and returns a new concurrent-safe object for uint64 type.
func (*Uint64) DeepCopy ¶
func (v *Uint64) DeepCopy() interface{}
DeepCopy implements interface for deep copy of current type.
func (Uint64) MarshalJSON ¶
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*Uint64) Set ¶
Set atomically stores `value` into t.value and returns the previous value of t.value.
func (*Uint64) String ¶
String implements String interface for string printing.
func (*Uint64) UnmarshalJSON ¶
UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.
func (*Uint64) UnmarshalValue ¶
UnmarshalValue is an interface implement which sets any type of value for `v`.