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.

118 lines
2.4 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 syns
import (
"sync/atomic"
"time"
)
type (
// ADuration
// Type: Struct
//
// Desc:
//
//
ADuration struct {
value int64
}
)
// NewADuration
// Desc: Función constructor para ADuration
//
// Prms: val, valor inicial
// Rets: Puntero al nuevo objeto creado.
//
func NewADuration(val time.Duration) *ADuration { return &ADuration{value: int64(val)} }
// ADuration.Get
// Desc:
// Prms:
// Rets:
//
func (i *ADuration) Get() time.Duration { return time.Duration(atomic.LoadInt64(&i.value)) }
// ADuration.Set
// Desc:
// Prms:
// Rets:
//
func (i *ADuration) Set(val time.Duration) { atomic.StoreInt64(&i.value, int64(val)) }
// ADuration.Swap
// Desc:
// Prms:
// Rets:
//
func (i *ADuration) Swap(new time.Duration) time.Duration {
return time.Duration(atomic.SwapInt64(&i.value, int64(new)))
}
// ADuration.Add
// Desc:
// Prms:
// Rets:
//
func (i *ADuration) Add(dlt time.Duration) time.Duration {
return time.Duration(atomic.AddInt64(&i.value, int64(dlt)))
}
// ADuration.Sub
// Desc:
// Prms:
// Rets:
//
func (i *ADuration) Sub(dlt time.Duration) time.Duration {
return time.Duration(atomic.AddInt64(&i.value, int64(-dlt)))
}
// ADuration.CAS
// Desc:
// Prms:
// Rets:
//
func (i *ADuration) CAS(old, new time.Duration) bool {
return atomic.CompareAndSwapInt64(&i.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 -
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
*/

Powered by TurnKey Linux.