From 676e32ad720b1d379f8168c2792133a34dc52bcb Mon Sep 17 00:00:00 2001 From: David Crawshaw Date: Tue, 22 Jun 2021 12:46:21 -0700 Subject: [PATCH] syncs: add AtomicUint32 Signed-off-by: David Crawshaw --- syncs/syncs.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/syncs/syncs.go b/syncs/syncs.go index f319f6489..46861af63 100644 --- a/syncs/syncs.go +++ b/syncs/syncs.go @@ -83,6 +83,17 @@ func (b *AtomicBool) Get() bool { return atomic.LoadInt32((*int32)(b)) != 0 } +// AtomicUint32 is an atomic uint32. +type AtomicUint32 uint32 + +func (b *AtomicUint32) Set(v uint32) { + atomic.StoreUint32((*uint32)(b), v) +} + +func (b *AtomicUint32) Get() uint32 { + return atomic.LoadUint32((*uint32)(b)) +} + // Semaphore is a counting semaphore. // // Use NewSemaphore to create one.