// // 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. // // +build amd64 arm64 ppc64 ppc64le mips64 mips64le s390x package syncs import ( "sync/atomic" ) type ( // AInt // Type: Struct // Desc: // AInt struct { value int64 } ) // NewAInt // Desc: Función constructor para AInt // // Prms: val, valor inicial // Rets: Puntero al nuevo objeto creado. // func NewAInt(val int) *AInt { return &AInt{value: int64(val)} } // AInt.Get // Desc: // Prms: // Rets: // func (u *AInt) Get() int { return int(atomic.LoadInt64(&u.value)) } // AInt.Set // Desc: // Prms: // Rets: // func (u *AInt) Set(v int) { atomic.StoreInt64(&u.value, int64(v)) } // AInt.Swap // Desc: // Prms: // Rets: // func (u *AInt) Swap(new int) int { return int(atomic.SwapInt64(&u.value, int64(new))) } // AInt.Add // Desc: // Prms: // Rets: // func (u *AInt) Add(dlt int) int { return int(atomic.AddInt64(&u.value, int64(dlt))) } // AInt.Sub // Desc: // Prms: // Rets: // func (u *AInt) Sub(dlt int) int { return int(atomic.AddInt64(&u.value, int64(-dlt))) } // AInt.Inc // Desc: // Prms: // Rets: // func (u *AInt) Inc() int { return u.Add(1) } // AInt.Dec // Desc: // Prms: // Rets: // func (u *AInt) Dec() int { return u.Add(-1) } // AInt.CAS // Desc: // Prms: // Rets: // func (u *AInt) CAS(old, new int) bool { return atomic.CompareAndSwapInt64(&u.value, int64(old), int64(new)) } /* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: I HAVE NO DESIRE TO WALK ON WATER," SAID SIDDHARTA. "LET THE OLD SHRAMANAS SATISFY THEMSELVES WITH SUCH SKILLS. SIDDHARTA - HERMANN HESSE - ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: */