You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Rx.NET/Source/src/System.Reactive/Disposables/SerialDisposable.cs
+27-34Lines changed: 27 additions & 34 deletions
Original file line number
Diff line number
Diff line change
@@ -2,19 +2,19 @@
2
2
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
3
3
// See the LICENSE file in the project root for more information.
4
4
5
+
usingSystem.Threading;
6
+
5
7
namespaceSystem.Reactive.Disposables
6
8
{
7
9
/// <summary>
8
10
/// Represents a disposable resource whose underlying disposable resource can be replaced by another disposable resource, causing automatic disposal of the previous underlying disposable resource.
9
11
/// </summary>
10
12
publicsealedclassSerialDisposable:ICancelable
11
13
{
12
-
privatereadonlyobject_gate=newobject();
13
14
privateIDisposable_current;
14
-
privatebool_disposed;
15
15
16
16
/// <summary>
17
-
/// Initializes a new instance of the <see cref="SerialDisposable"/> class.
17
+
/// Initializes a new instance of the <see cref="T:System.Reactive.Disposables.SerialDisposable"/> class.
18
18
/// </summary>
19
19
publicSerialDisposable()
20
20
{
@@ -27,10 +27,10 @@ public bool IsDisposed
27
27
{
28
28
get
29
29
{
30
-
lock(_gate)
31
-
{
32
-
return_disposed;
33
-
}
30
+
// We use a sentinel value to indicate we've been disposed. This sentinel never leaks
31
+
// to the outside world (see the Disposable property getter), so no-one can ever assign
0 commit comments