// // 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 ( // AUInt64 // Type: Struct // Desc: // // AUInt64 struct { value uint64 } ) // NewAUInt64 // Desc: Función constructor para AUInt64 // // Prms: val, valor inicial // Rets: Puntero al nuevo objeto creado. // func NewAUInt64(val uint64) *AUInt64 { return &AUInt64{value: val} } // AUInt64.Get // Desc: // Prms: // Rets: // func (u *AUInt64) Get() uint64 { return atomic.LoadUint64(&u.value) } // AUInt64.Set // Desc: // Prms: // Rets: // func (u *AUInt64) Set(val uint64) { atomic.StoreUint64(&u.value, val) } // AUInt64.Swap // Desc: // Prms: // Rets: // func (u *AUInt64) Swap(new uint64) uint64 { return atomic.SwapUint64(&u.value, new) } // AUInt64.Add // Desc: // Prms: // Rets: // func (u *AUInt64) Add(dlt uint64) uint64 { return atomic.AddUint64(&u.value, dlt) } // AUInt64.Sub // Desc: // Prms: // Rets: // func (u *AUInt64) Sub(dlt uint64) uint64 { return atomic.AddUint64(&u.value, ^uint64(dlt-1)) } // AUInt64.Inc // Desc: // Prms: // Rets: // func (u *AUInt64) Inc() uint64 { return u.Add(1) } // AUInt64.Dec // Desc: // Prms: // Rets: // func (u *AUInt64) Dec() uint64 { return u.Add(^uint64(0)) } // AUInt64.CAS // Desc: // Prms: // Rets: // func (u *AUInt64) CAS(old, new uint64) bool { return atomic.CompareAndSwapUint64(&u.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 - ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: */