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
@@ -119,22 +120,22 @@ public final class RedisConnection: RedisClient {
119
120
/// - Important: Even when set to `true`, the host machine may still choose to delay sending commands.
120
121
/// - Note: Setting this to `true` will immediately drain the buffer.
121
122
public var sendCommandsImmediately : Bool {
122
- get { return autoflush. load ( ) }
123
+ get { return autoflush. load ( ordering : . sequentiallyConsistent ) }
123
124
set ( newValue) {
124
125
if newValue { self . channel. flush ( ) }
125
- autoflush. store ( newValue)
126
+ autoflush. store ( newValue, ordering : . sequentiallyConsistent )
126
127
}
127
128
}
128
129
/// Controls the permission of the connection to be able to have PubSub subscriptions or not.
129
130
///
130
131
/// When set to `true`, this connection is allowed to create subscriptions.
131
132
/// When set to `false`, this connection is not allowed to create subscriptions. Any potentially existing subscriptions will be removed.
132
133
public var allowSubscriptions : Bool {
133
- get { self . allowPubSub. load ( ) }
134
+ get { self . allowPubSub. load ( ordering : . sequentiallyConsistent ) }
134
135
set ( newValue) {
135
- self . allowPubSub. store ( newValue)
136
+ self . allowPubSub. store ( newValue, ordering : . sequentiallyConsistent )
136
137
// if we're subscribed, and we're not allowed to be in pubsub, end our subscriptions
137
- guard self . isSubscribed && !self . allowPubSub. load ( ) else { return }
138
+ guard self . isSubscribed && !self . allowPubSub. load ( ordering : . sequentiallyConsistent ) else { return }
138
139
_ = EventLoopFuture< Void> . whenAllComplete( [
139
140
self . unsubscribe ( ) ,
140
141
self . punsubscribe ( )
@@ -149,8 +150,8 @@ public final class RedisConnection: RedisClient {
149
150
150
151
internal let channel : Channel
151
152
152
- private let autoflush : NIOAtomic < Bool > = . makeAtomic ( value : true )
153
- private let allowPubSub : NIOAtomic < Bool > = . makeAtomic ( value : true )
153
+ private let autoflush = ManagedAtomic < Bool > ( true )
154
+ private let allowPubSub = ManagedAtomic < Bool > ( true )
154
155
private let _stateLock = Lock ( )
155
156
private var _state = ConnectionState . open
156
157
private var state : ConnectionState {
0 commit comments