12
12
//
13
13
//===----------------------------------------------------------------------===//
14
14
15
+ import Atomics
15
16
import NIOCore
16
17
import NIOConcurrencyHelpers
17
18
@@ -164,8 +165,8 @@ final class HTTP2StreamChannel: Channel, ChannelCore {
164
165
self . streamID = streamID
165
166
self . multiplexer = multiplexer
166
167
self . windowManager = InboundWindowManager ( targetSize: Int32 ( targetWindowSize) )
167
- self . _isActiveAtomic = . makeAtomic ( value : false )
168
- self . _isWritable = . makeAtomic ( value : true )
168
+ self . _isActiveAtomic = . init ( false )
169
+ self . _isWritable = . init ( true )
169
170
self . state = . idle
170
171
self . streamDataType = streamDataType
171
172
self . writabilityManager = StreamChannelFlowController ( highWatermark: outboundBytesHighWatermark,
@@ -307,10 +308,10 @@ final class HTTP2StreamChannel: Channel, ChannelCore {
307
308
}
308
309
self . modifyingState { $0. networkActive ( ) }
309
310
310
- if self . writabilityManager. isWritable != self . _isWritable. load ( ) {
311
+ if self . writabilityManager. isWritable != self . _isWritable. load ( ordering : . relaxed ) {
311
312
// We have probably delayed telling the user that this channel isn't writable, but we should do
312
313
// it now.
313
- self . _isWritable. store ( self . writabilityManager. isWritable)
314
+ self . _isWritable. store ( self . writabilityManager. isWritable, ordering : . relaxed )
314
315
self . pipeline. fireChannelWritabilityChanged ( )
315
316
}
316
317
@@ -404,20 +405,20 @@ final class HTTP2StreamChannel: Channel, ChannelCore {
404
405
}
405
406
406
407
public var isWritable : Bool {
407
- return self . _isWritable. load ( )
408
+ return self . _isWritable. load ( ordering : . relaxed )
408
409
}
409
410
410
- private let _isWritable : NIOAtomic < Bool >
411
+ private let _isWritable : ManagedAtomic < Bool >
411
412
412
413
private var _isActive : Bool {
413
414
return self . state == . active || self . state == . closing || self . state == . localActive
414
415
}
415
416
416
417
public var isActive : Bool {
417
- return self . _isActiveAtomic. load ( )
418
+ return self . _isActiveAtomic. load ( ordering : . relaxed )
418
419
}
419
420
420
- private let _isActiveAtomic : NIOAtomic < Bool >
421
+ private let _isActiveAtomic : ManagedAtomic < Bool >
421
422
422
423
public var _channelCore : ChannelCore {
423
424
return self
@@ -663,7 +664,7 @@ final class HTTP2StreamChannel: Channel, ChannelCore {
663
664
}
664
665
665
666
private func changeWritability( to newWritability: Bool ) {
666
- self . _isWritable. store ( newWritability)
667
+ self . _isWritable. store ( newWritability, ordering : . relaxed )
667
668
self . pipeline. fireChannelWritabilityChanged ( )
668
669
}
669
670
@@ -869,7 +870,7 @@ internal extension HTTP2StreamChannel {
869
870
// Do nothing here.
870
871
return
871
872
case . remoteActive, . active, . closing, . closingNeverActivated, . closed:
872
- self . _isWritable. store ( localValue)
873
+ self . _isWritable. store ( localValue, ordering : . relaxed )
873
874
self . pipeline. fireChannelWritabilityChanged ( )
874
875
}
875
876
}
@@ -884,7 +885,7 @@ extension HTTP2StreamChannel {
884
885
// A helper function used to ensure that state modification leads to changes in the channel active atomic.
885
886
private func modifyingState< ReturnType> ( _ closure: ( inout StreamChannelState ) throws -> ReturnType ) rethrows -> ReturnType {
886
887
defer {
887
- self . _isActiveAtomic. store ( self . _isActive)
888
+ self . _isActiveAtomic. store ( self . _isActive, ordering : . relaxed )
888
889
}
889
890
return try closure ( & self . state)
890
891
}
0 commit comments