File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed
Sources/NautilusTelemetry/Utilities Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change 22// Copyright © 2025 Airbnb Inc. All rights reserved.
33
44import Foundation
5+ import os
56
67// MARK: - FlushTimer
78
@@ -42,10 +43,12 @@ class FlushTimer {
4243 }
4344
4445 func suspend( ) {
45- if !suspended {
46- // Must match calls between suspend/resume
47- flushTimer. suspend ( )
48- suspended = true
46+ lock. withLock {
47+ if !suspended {
48+ // Must match calls between suspend/resume
49+ flushTimer. suspend ( )
50+ suspended = true
51+ }
4952 }
5053 }
5154
@@ -59,16 +62,18 @@ class FlushTimer {
5962 leeway: DispatchTimeInterval . milliseconds ( 100 )
6063 )
6164 flushTimer. activate ( )
62- if suspended {
63- flushTimer. resume ( )
64- suspended = false
65+ lock. withLock {
66+ if suspended {
67+ flushTimer. resume ( )
68+ suspended = false
69+ }
6570 }
6671 }
6772
6873 // MARK: Private
6974
7075 private var _flushInterval : TimeInterval
71-
76+ private var lock = OSAllocatedUnfairLock ( )
7277}
7378
7479extension DispatchTimeInterval {
You can’t perform that action at this time.
0 commit comments