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.
65 lines
1.9 KiB
65 lines
1.9 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.
|
|
//
|
|
|
|
// +build 386 arm mips mipsle
|
|
|
|
package syns
|
|
|
|
import (
|
|
"sync/atomic"
|
|
)
|
|
|
|
type AUInt struct{ value uint32 }
|
|
|
|
func NewAUint(v uint) *AUInt { return &AUInt{value: uint32(v)} }
|
|
|
|
func (u *AUInt) Get() uint { return uint(atomic.LoadUint32(&u.value)) }
|
|
func (u *AUInt) Set(v uint) { atomic.StoreUint32(&u.value, uint32(v)) }
|
|
func (u *AUInt) Swap(new uint) uint { return uint(atomic.SwapUint32(&u.value, uint32(new))) }
|
|
|
|
func (u *AUInt) Add(dlt uint) uint { return uint(atomic.AddUint32(&u.value, uint32(dlt))) }
|
|
func (u *AUInt) Sub(dlt uint) uint { return uint(atomic.AddUint32(&u.value, ^uint32(uint32(dlt)-1))) }
|
|
func (u *AUInt) Inc() uint { return u.Add(1) }
|
|
func (u *AUInt) Dec() uint { return u.Add(uint(^uint32(0))) }
|
|
|
|
func (u *AUInt) CAS(old, new uint) bool {
|
|
return atomic.CompareAndSwapUint32(&u.value, uint32(old), uint32(new))
|
|
}
|
|
|
|
/*
|
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
|
|
I HAVE NO DESIRE TO WALK ON WATER," SAID SIDDHARTA.
|
|
"LET THE OLD SHRAMANAS SATISFY THEMSELVES WITH SUCH SKILLS.
|
|
|
|
SIDDHARTA
|
|
- HERMANN HESSE -
|
|
|
|
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
|
|
*/
|