@@ -53,10 +53,7 @@ public void Reset()
5353 // The outer user always ensures that the state is not accessed across
5454 // the reset point when implementing Rent/Return operations.
5555 _version ++ ;
56- Debug . Assert ( _continuation == null || IsCompleted ) ;
5756 _continuation = null ;
58- Debug . Assert ( _continuationState == null ) ;
59- Debug . Assert ( _capturedContext == null ) ;
6057 _continuationState = null ;
6158 _capturedContext = null ;
6259 _error = null ;
@@ -232,20 +229,14 @@ private void SignalCompletion()
232229 ThrowHelper . ThrowInvalidOperationException ( ) ;
233230 }
234231
235- Action < object ? > ? continuation =
236- Volatile . Read ( ref _continuation ) ??
237- Interlocked . CompareExchange ( ref _continuation , ManualResetValueTaskSourceCoreShared . s_sentinel , null ) ;
232+ Action < object ? > ? continuation = Interlocked . Exchange ( ref _continuation , ManualResetValueTaskSourceCoreShared . s_sentinel ) ;
238233
239234 if ( continuation is not null )
240235 {
241236 object ? state = _continuationState ;
242237 _continuationState = null ;
243238 object ? context = _capturedContext ;
244239 _capturedContext = null ;
245- // NB: this write must happen after setting result/error, but
246- // _continuation is set to not-null via CAS after setting result/error,
247- // and this write is after that.
248- _continuation = ManualResetValueTaskSourceCoreShared . s_sentinel ;
249240
250241 if ( context is null )
251242 {
0 commit comments