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.8 KiB
65 lines
1.8 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 AInt struct{ value int32 }
|
|
|
|
func NewAInt(v int) *AInt { return &AInt{value: int32(v)} }
|
|
|
|
func (u *AInt) Get() int { return int(atomic.LoadInt32(&u.value)) }
|
|
func (u *AInt) Set(v int) { atomic.StoreInt32(&u.value, int32(v)) }
|
|
func (u *AInt) Swap(new int) int { return int(atomic.SwapInt32(&u.value, int32(new))) }
|
|
|
|
func (u *AInt) Add(dlt int) int { return int(atomic.AddInt32(&u.value, int32(dlt))) }
|
|
func (u *AInt) Sub(dlt int) int { return int(atomic.AddInt32(&u.value, -dlt)) }
|
|
func (u *AInt) Inc() int { return u.Add(1) }
|
|
func (u *AInt) Dec() int { return u.Add(-1) }
|
|
|
|
func (u *AInt) CAS(old, new int) bool {
|
|
return atomic.CompareAndSwapInt32(&u.value, int32(old), int32(new))
|
|
}
|
|
|
|
/*
|
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
|
|
I HAVE NO DESIRE TO WALK ON WATER," SAID SIDDHARTA.
|
|
"LET THE OLD SHRAMANAS SATISFY THEMSELVES WITH SUCH SKILLS.
|
|
|
|
SIDDHARTA
|
|
- HERMANN HESSE -
|
|
|
|
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
|
|
*/
|