You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
122 lines
2.3 KiB
122 lines
2.3 KiB
//
|
|
// Feb21
|
|
//
|
|
// GO Active Thing
|
|
// Framework
|
|
//
|
|
// http://activething.com/dev/goat
|
|
//
|
|
// Dev : Juan V.Navarro
|
|
// Email: juanvnl@activething.com
|
|
// Date : 16/02/2021
|
|
//
|
|
// Copyright 2021 the GOAT Authors
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
//
|
|
|
|
package syns
|
|
|
|
import (
|
|
"sync/atomic"
|
|
)
|
|
|
|
type (
|
|
|
|
// AInt32
|
|
// Type: Struct
|
|
// Desc:
|
|
//
|
|
//
|
|
AInt32 struct {
|
|
value int32
|
|
}
|
|
)
|
|
|
|
// NewAInt32
|
|
// Desc: Función constructor para AInt32
|
|
//
|
|
// Prms: val, valor inicial
|
|
// Rets: Puntero al nuevo objeto creado.
|
|
//
|
|
func NewAInt32(val int32) *AInt32 { return &AInt32{value: val} }
|
|
|
|
// AInt32.Get
|
|
// Desc:
|
|
// Prms:
|
|
// Rets:
|
|
//
|
|
func (i *AInt32) Get() int32 { return atomic.LoadInt32(&i.value) }
|
|
|
|
// AInt32.Set
|
|
// Desc:
|
|
// Prms:
|
|
// Rets:
|
|
//
|
|
func (i *AInt32) Set(val int32) { atomic.StoreInt32(&i.value, val) }
|
|
|
|
// AInt32.Swap
|
|
// Desc:
|
|
// Prms:
|
|
// Rets:
|
|
//
|
|
func (i *AInt32) Swap(new int32) int32 { return atomic.SwapInt32(&i.value, new) }
|
|
|
|
// AInt32.Add
|
|
// Desc:
|
|
// Prms:
|
|
// Rets:
|
|
//
|
|
func (i *AInt32) Add(dlt int32) int32 { return atomic.AddInt32(&i.value, dlt) }
|
|
|
|
// AInt32.Sub
|
|
// Desc:
|
|
// Prms:
|
|
// Rets:
|
|
//
|
|
func (i *AInt32) Sub(dlt int32) int32 { return atomic.AddInt32(&i.value, -dlt) }
|
|
|
|
// AInt32.Inc
|
|
// Desc:
|
|
// Prms:
|
|
// Rets:
|
|
//
|
|
func (i *AInt32) Inc() int32 { return i.Add(1) }
|
|
|
|
// AInt32.Dec
|
|
// Desc:
|
|
// Prms:
|
|
// Rets:
|
|
//
|
|
func (i *AInt32) Dec() int32 { return i.Add(-1) }
|
|
|
|
// AInt32.CAS
|
|
// Desc:
|
|
// Prms:
|
|
// Rets:
|
|
//
|
|
func (i *AInt32) CAS(old, new int32) bool { return atomic.CompareAndSwapInt32(&i.value, old, new) }
|
|
|
|
/*
|
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
|
|
I HAVE NO DESIRE TO WALK ON WATER," SAID SIDDHARTA.
|
|
"LET THE OLD SHRAMANAS SATISFY THEMSELVES WITH SUCH SKILLS.
|
|
|
|
SIDDHARTA
|
|
- HERMANN HESSE -
|
|
|
|
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
|
|
*/
|