types: add an Atomic64 type

Change-Id: I4677b4368b98e658b921697331d999b58de85d7f
This commit is contained in:
Brad Fitzpatrick 2013-07-21 20:45:20 -07:00
parent 1149058dbd
commit 2789f65d1f
1 changed files with 16 additions and 0 deletions

View File

@ -37,3 +37,19 @@ func (b *AtomicBool) Set(v bool) {
}
atomic.StoreUint32(&b.v, 0)
}
type AtomicInt64 struct {
v int64
}
func (a *AtomicInt64) Get() int64 {
return atomic.LoadInt64(&a.v)
}
func (a *AtomicInt64) Set(v int64) {
atomic.StoreInt64(&a.v, v)
}
func (a *AtomicInt64) Add(delta int64) int64 {
return atomic.AddInt64(&a.v, delta)
}