From ada3cebe1055442f2af2840ed42cd50f64bbc6f7 Mon Sep 17 00:00:00 2001 From: siddontang Date: Wed, 15 Oct 2014 09:20:35 +0800 Subject: [PATCH] update --- sync2/atomic.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sync2/atomic.go b/sync2/atomic.go index 909f3b1..394d780 100644 --- a/sync2/atomic.go +++ b/sync2/atomic.go @@ -64,6 +64,24 @@ func (i *AtomicInt64) CompareAndSwap(oldval, newval int64) (swapped bool) { return atomic.CompareAndSwapInt64((*int64)(i), oldval, newval) } +type AtomicUint64 uint64 + +func (i *AtomicUint64) Add(n uint64) uint64 { + return atomic.AddUint64((*uint64)(i), n) +} + +func (i *AtomicUint64) Set(n uint64) { + atomic.StoreUint64((*uint64)(i), n) +} + +func (i *AtomicUint64) Get() uint64 { + return atomic.LoadUint64((*uint64)(i)) +} + +func (i *AtomicUint64) CompareAndSwap(oldval, newval uint64) (swapped bool) { + return atomic.CompareAndSwapUint64((*uint64)(i), oldval, newval) +} + type AtomicDuration int64 func (d *AtomicDuration) Add(duration time.Duration) time.Duration {