14
14
15
15
import struct Foundation. UUID
16
16
import struct Dispatch. DispatchTime
17
+ import Atomics
17
18
import Logging
18
19
import Metrics
19
20
import NIO
@@ -117,22 +118,22 @@ public final class RedisConnection: RedisClient, RedisClientWithUserContext {
117
118
/// - Important: Even when set to `true`, the host machine may still choose to delay sending commands.
118
119
/// - Note: Setting this to `true` will immediately drain the buffer.
119
120
public var sendCommandsImmediately : Bool {
120
- get { return autoflush. load ( ) }
121
+ get { return autoflush. load ( ordering : . sequentiallyConsistent ) }
121
122
set ( newValue) {
122
123
if newValue { self . channel. flush ( ) }
123
- autoflush. store ( newValue)
124
+ autoflush. store ( newValue, ordering : . sequentiallyConsistent )
124
125
}
125
126
}
126
127
/// Controls the permission of the connection to be able to have PubSub subscriptions or not.
127
128
///
128
129
/// When set to `true`, this connection is allowed to create subscriptions.
129
130
/// When set to `false`, this connection is not allowed to create subscriptions. Any potentially existing subscriptions will be removed.
130
131
public var allowSubscriptions : Bool {
131
- get { self . allowPubSub. load ( ) }
132
+ get { self . allowPubSub. load ( ordering : . sequentiallyConsistent ) }
132
133
set ( newValue) {
133
- self . allowPubSub. store ( newValue)
134
+ self . allowPubSub. store ( newValue, ordering : . sequentiallyConsistent )
134
135
// 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 }
136
137
_ = EventLoopFuture< Void> . whenAllComplete( [
137
138
self . unsubscribe ( ) ,
138
139
self . punsubscribe ( )
@@ -147,9 +148,9 @@ public final class RedisConnection: RedisClient, RedisClientWithUserContext {
147
148
internal let channel : Channel
148
149
private let systemContext : Context
149
150
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 )
153
154
private let _stateLock = NIOLock ( )
154
155
private var _state = ConnectionState . open
155
156
private var state : ConnectionState {
0 commit comments