1212//
1313//===----------------------------------------------------------------------===//
1414
15- #if swift(>=5.6)
16- @preconcurrency import NIOCore
17- #else
18- import NIOCore
19- #endif
15+ import Atomics
2016import NIOConcurrencyHelpers
17+ import NIOCore
2118
2219/// A NIO `Channel` that encapsulates a single SSH `Channel`.
2320///
@@ -90,9 +87,9 @@ final class SSHChildChannel {
9087
9188 public let eventLoop : EventLoop
9289
93- private let _isWritable : NIOAtomic < Bool >
90+ private let _isWritable : ManagedAtomic < Bool >
9491
95- private let _isActive : NIOAtomic < Bool >
92+ private let _isActive : ManagedAtomic < Bool >
9693
9794 typealias Initializer = ( Channel , SSHChannelType ) -> EventLoopFuture < Void >
9895
@@ -135,8 +132,8 @@ final class SSHChildChannel {
135132 self . multiplexer = multiplexer
136133 self . initializer = initializer
137134 self . windowManager = ChildChannelWindowManager ( targetWindowSize: UInt32 ( targetWindowSize) )
138- self . _isWritable = . makeAtomic ( value : true )
139- self . _isActive = . makeAtomic ( value : false )
135+ self . _isWritable = . init ( true )
136+ self . _isActive = . init ( false )
140137 self . state = initialState
141138 self . writabilityManager = ChildChannelWritabilityManager ( initialWindowSize: initialOutboundWindowSize,
142139 parentIsWritable: parent. isWritable)
@@ -240,11 +237,11 @@ extension SSHChildChannel: Channel, ChannelCore {
240237 }
241238
242239 public var isWritable : Bool {
243- self . _isWritable. load ( )
240+ self . _isWritable. load ( ordering : . relaxed )
244241 }
245242
246243 public var isActive : Bool {
247- self . _isActive. load ( )
244+ self . _isActive. load ( ordering : . relaxed )
248245 }
249246
250247 public var _channelCore : ChannelCore {
@@ -618,7 +615,7 @@ extension SSHChildChannel: Channel, ChannelCore {
618615 }
619616
620617 private func changeWritability( to newWritability: Bool ) {
621- self . _isWritable. store ( newWritability)
618+ self . _isWritable. store ( newWritability, ordering : . relaxed )
622619 self . pipeline. fireChannelWritabilityChanged ( )
623620 }
624621
@@ -1030,14 +1027,14 @@ extension SSHChildChannel {
10301027 switch self . activationState {
10311028 case . neverActivated:
10321029 self . activationState = . activated
1033- self . _isActive. store ( true )
1030+ self . _isActive. store ( true , ordering : . relaxed )
10341031 self . pipeline. fireChannelActive ( )
10351032
10361033 case . activated:
1037- assert ( self . _isActive. load ( ) == true )
1034+ assert ( self . _isActive. load ( ordering : . relaxed ) == true )
10381035
10391036 case . deactivated:
1040- assert ( self . _isActive. load ( ) == false )
1037+ assert ( self . _isActive. load ( ordering : . relaxed ) == false )
10411038 }
10421039 }
10431040
@@ -1046,15 +1043,15 @@ extension SSHChildChannel {
10461043 case . neverActivated:
10471044 // Do nothing, transition to inactive.
10481045 self . activationState = . deactivated
1049- assert ( self . _isActive. load ( ) == false )
1046+ assert ( self . _isActive. load ( ordering : . relaxed ) == false )
10501047
10511048 case . activated:
10521049 self . activationState = . deactivated
1053- self . _isActive. store ( false )
1050+ self . _isActive. store ( false , ordering : . relaxed )
10541051 self . pipeline. fireChannelInactive ( )
10551052
10561053 case . deactivated:
1057- assert ( self . _isActive. load ( ) == false )
1054+ assert ( self . _isActive. load ( ordering : . relaxed ) == false )
10581055 }
10591056 }
10601057}
0 commit comments