mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
test: use typed atomics in test files (#25071)
Use typed atomics (atomic.Int64, atomic.Int32, etc.) in test files to prevent mixing atomic and non-atomic access on the same value, guarantee 64-bit alignment on 32-bit platforms, and provide a cleaner API.
This commit is contained in:
@@ -407,7 +407,7 @@ func (failingHealthcheck) Ping(context.Context) (time.Duration, error) {
|
||||
|
||||
type wrappedListener struct {
|
||||
net.Listener
|
||||
dials int32
|
||||
dials atomic.Int32
|
||||
}
|
||||
|
||||
func (w *wrappedListener) Accept() (net.Conn, error) {
|
||||
@@ -416,12 +416,12 @@ func (w *wrappedListener) Accept() (net.Conn, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
atomic.AddInt32(&w.dials, 1)
|
||||
w.dials.Add(1)
|
||||
return conn, nil
|
||||
}
|
||||
|
||||
func (w *wrappedListener) getDials() int {
|
||||
return int(atomic.LoadInt32(&w.dials))
|
||||
return int(w.dials.Load())
|
||||
}
|
||||
|
||||
type agentWithID struct {
|
||||
|
||||
Reference in New Issue
Block a user