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 syncs
|
|
|
|
import (
|
|
"sync/atomic"
|
|
)
|
|
|
|
type (
|
|
|
|
// AUInt32
|
|
// Type: Struct
|
|
// Desc:
|
|
//
|
|
//
|
|
AUInt32 struct {
|
|
value uint32
|
|
}
|
|
)
|
|
|
|
// NewAUInt32
|
|
// Desc: Función constructor para AUInt32
|
|
//
|
|
// Prms: val, valor inicial
|
|
// Rets: Puntero al nuevo objeto creado.
|
|
//
|
|
func NewAUInt32(val uint32) *AUInt32 { return &AUInt32{value: val} }
|
|
|
|
// AUInt32.Get
|
|
// Desc:
|
|
// Prms:
|
|
// Rets:
|
|
//
|
|
func (u *AUInt32) Get() uint32 { return atomic.LoadUint32(&u.value) }
|
|
|
|
// AUInt32.Set
|
|
// Desc:
|
|
// Prms:
|
|
// Rets:
|
|
//
|
|
func (u *AUInt32) Set(val uint32) { atomic.StoreUint32(&u.value, val) }
|
|
|
|
// AUInt32.Swap
|
|
// Desc:
|
|
// Prms:
|
|
// Rets:
|
|
//
|
|
func (u *AUInt32) Swap(new uint32) uint32 { return atomic.SwapUint32(&u.value, new) }
|
|
|
|
// AUInt32.Add
|
|
// Desc:
|
|
// Prms:
|
|
// Rets:
|
|
//
|
|
func (u *AUInt32) Add(dlt uint32) uint32 { return atomic.AddUint32(&u.value, dlt) }
|
|
|
|
// AUInt32.Sub
|
|
// Desc:
|
|
// Prms:
|
|
// Rets:
|
|
//
|
|
func (u *AUInt32) Sub(dlt uint32) uint32 { return atomic.AddUint32(&u.value, ^uint32(dlt-1)) }
|
|
|
|
// AUInt32.Inc
|
|
// Desc:
|
|
// Prms:
|
|
// Rets:
|
|
//
|
|
func (u *AUInt32) Inc() uint32 { return u.Add(1) }
|
|
|
|
// AUInt32.Dec
|
|
// Desc:
|
|
// Prms:
|
|
// Rets:
|
|
//
|
|
func (u *AUInt32) Dec() uint32 { return u.Add(^uint32(0)) }
|
|
|
|
// AUInt32.CAS
|
|
// Desc:
|
|
// Prms:
|
|
// Rets:
|
|
//
|
|
func (u *AUInt32) CAS(old, new uint32) bool { return atomic.CompareAndSwapUint32(&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 -
|
|
|
|
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
|
|
*/
|