-
Notifications
You must be signed in to change notification settings - Fork 754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use the helper methods for IDisposable-fields, avoid repeating code patterns #556
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,10 +68,8 @@ void Drain() | |
var enumerator = stack.Pop(); | ||
enumerator.Dispose(); | ||
} | ||
if (Volatile.Read(ref currentSubscription) != BooleanDisposable.True) | ||
{ | ||
Interlocked.Exchange(ref currentSubscription, BooleanDisposable.True)?.Dispose(); | ||
} | ||
|
||
Disposable.TryDispose(ref currentSubscription); | ||
} | ||
else | ||
{ | ||
|
@@ -131,7 +129,8 @@ void Drain() | |
else | ||
{ | ||
var sad = new SingleAssignmentDisposable(); | ||
if (Interlocked.CompareExchange(ref currentSubscription, sad, null) == null) | ||
|
||
if (Disposable.TrySetSingle(ref currentSubscription, sad) == TrySetSingleResult.Success) | ||
{ | ||
sad.Disposable = next.SubscribeSafe(this); | ||
} | ||
|
@@ -172,15 +171,8 @@ void DisposeAll() | |
|
||
protected void Recurse() | ||
{ | ||
var d = Volatile.Read(ref currentSubscription); | ||
if (d != BooleanDisposable.True) | ||
{ | ||
d?.Dispose(); | ||
if (Interlocked.CompareExchange(ref currentSubscription, null, d) == d) | ||
{ | ||
Drain(); | ||
} | ||
} | ||
if (Disposable.TrySetSerial(ref currentSubscription, null)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this still capture the original semantics? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a loop in |
||
Drain(); | ||
} | ||
|
||
protected abstract IEnumerable<IObservable<TSource>> Extract(IObservable<TSource> source); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@akarnokd This change was added (the original reason to split SetSingle and TrySetSingle).