Skip to content

Commit

Permalink
utils: update atomic2.Int64
Browse files Browse the repository at this point in the history
  • Loading branch information
spinlock committed Dec 28, 2017
1 parent ad6834b commit 9fde280
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions pkg/utils/sync2/atomic2/atomic64.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,30 @@ package atomic2

import "sync/atomic"

type Int64 struct {
v int64
}
type Int64 int64

func (a *Int64) Int64() int64 {
return atomic.LoadInt64(&a.v)
return atomic.LoadInt64((*int64)(a))
}

func (a *Int64) AsInt() int {
return int(a.Int64())
}

func (a *Int64) Set(v int64) {
atomic.StoreInt64(&a.v, v)
atomic.StoreInt64((*int64)(a), v)
}

func (a *Int64) CompareAndSwap(o, n int64) bool {
return atomic.CompareAndSwapInt64(&a.v, o, n)
return atomic.CompareAndSwapInt64((*int64)(a), o, n)
}

func (a *Int64) Swap(v int64) int64 {
return atomic.SwapInt64(&a.v, v)
return atomic.SwapInt64((*int64)(a), v)
}

func (a *Int64) Add(v int64) int64 {
return atomic.AddInt64(&a.v, v)
return atomic.AddInt64((*int64)(a), v)
}

func (a *Int64) Sub(v int64) int64 {
Expand Down

0 comments on commit 9fde280

Please sign in to comment.