1414
1515import struct Foundation. UUID
1616import struct Dispatch. DispatchTime
17+ import Atomics
1718import Logging
1819import Metrics
1920import NIO
@@ -117,22 +118,22 @@ public final class RedisConnection: RedisClient, RedisClientWithUserContext {
117118 /// - Important: Even when set to `true`, the host machine may still choose to delay sending commands.
118119 /// - Note: Setting this to `true` will immediately drain the buffer.
119120 public var sendCommandsImmediately : Bool {
120- get { return autoflush. load ( ) }
121+ get { return autoflush. load ( ordering : . sequentiallyConsistent ) }
121122 set ( newValue) {
122123 if newValue { self . channel. flush ( ) }
123- autoflush. store ( newValue)
124+ autoflush. store ( newValue, ordering : . sequentiallyConsistent )
124125 }
125126 }
126127 /// Controls the permission of the connection to be able to have PubSub subscriptions or not.
127128 ///
128129 /// When set to `true`, this connection is allowed to create subscriptions.
129130 /// When set to `false`, this connection is not allowed to create subscriptions. Any potentially existing subscriptions will be removed.
130131 public var allowSubscriptions : Bool {
131- get { self . allowPubSub. load ( ) }
132+ get { self . allowPubSub. load ( ordering : . sequentiallyConsistent ) }
132133 set ( newValue) {
133- self . allowPubSub. store ( newValue)
134+ self . allowPubSub. store ( newValue, ordering : . sequentiallyConsistent )
134135 // if we're subscribed, and we're not allowed to be in pubsub, end our subscriptions
135- guard self . isSubscribed && !self . allowPubSub. load ( ) else { return }
136+ guard self . isSubscribed && !self . allowPubSub. load ( ordering : . sequentiallyConsistent ) else { return }
136137 _ = EventLoopFuture< Void> . whenAllComplete( [
137138 self . unsubscribe ( ) ,
138139 self . punsubscribe ( )
@@ -147,9 +148,9 @@ public final class RedisConnection: RedisClient, RedisClientWithUserContext {
147148 internal let channel : Channel
148149 private let systemContext : Context
149150 private var logger : Logger { self . systemContext }
150-
151- private let autoflush : NIOAtomic < Bool > = . makeAtomic ( value : true )
152- private let allowPubSub : NIOAtomic < Bool > = . makeAtomic ( value : true )
151+
152+ private let autoflush = ManagedAtomic < Bool > ( true )
153+ private let allowPubSub = ManagedAtomic < Bool > ( true )
153154 private let _stateLock = NIOLock ( )
154155 private var _state = ConnectionState . open
155156 private var state : ConnectionState {
0 commit comments