Skip to content

Commit f164260

Browse files
committed
Obsolete token linkage methods in favor of CancellationTokenMultiplexer
1 parent aceddd2 commit f164260

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/DotNext.Tests/Threading/LinkedCancellationTokenSourceTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ namespace DotNext.Threading;
33
public sealed class LinkedCancellationTokenSourceTests : Test
44
{
55
[Fact]
6+
[Obsolete]
67
public static async Task LinkedCancellation()
78
{
89
using var source1 = new CancellationTokenSource();
@@ -25,6 +26,7 @@ public static async Task LinkedCancellation()
2526
}
2627

2728
[Fact]
29+
[Obsolete]
2830
public static async Task DirectCancellation()
2931
{
3032
using var source1 = new CancellationTokenSource();
@@ -47,6 +49,7 @@ public static async Task DirectCancellation()
4749
}
4850

4951
[Fact]
52+
[Obsolete]
5053
public static async Task CancellationWithTimeout()
5154
{
5255
using var source1 = new CancellationTokenSource();
@@ -59,6 +62,7 @@ public static async Task CancellationWithTimeout()
5962
}
6063

6164
[Fact]
65+
[Obsolete]
6266
public static async Task ConcurrentCancellation()
6367
{
6468
using var source1 = new CancellationTokenSource();

src/DotNext.Threading/Threading/LinkedTokenSourceFactory.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public static class LinkedTokenSourceFactory
1414
/// <param name="first">The first cancellation token. Can be modified by this method.</param>
1515
/// <param name="second">The second cancellation token.</param>
1616
/// <returns>The linked token source; or <see langword="null"/> if <paramref name="first"/> or <paramref name="second"/> is not cancelable.</returns>
17+
[Obsolete("Use CancellationTokenMultiplexer class instead.")]
1718
public static LinkedCancellationTokenSource? LinkTo(this ref CancellationToken first, CancellationToken second)
1819
=> LinkedCancellationTokenSource.Combine(ref first, second);
1920

@@ -23,6 +24,7 @@ public static class LinkedTokenSourceFactory
2324
/// <param name="first">The first cancellation token. Can be modified by this method.</param>
2425
/// <param name="tokens">A list of cancellation tokens to link together.</param>
2526
/// <returns>The linked token source; or <see langword="null"/> if <paramref name="first"/> or <paramref name="tokens"/> are not cancelable.</returns>
27+
[Obsolete("Use CancellationTokenMultiplexer class instead.")]
2628
public static LinkedCancellationTokenSource? LinkTo(this ref CancellationToken first, ReadOnlySpan<CancellationToken> tokens)
2729
{
2830
LinkedCancellationTokenSource? result;
@@ -53,6 +55,7 @@ public static class LinkedTokenSourceFactory
5355
/// <param name="token">The first cancellation token. Can be modified by this method.</param>
5456
/// <param name="timeout">The timeout to link.</param>
5557
/// <returns>The linked token source; or <see langword="null"/> if <paramref name="token"/> is canceled or <paramref name="timeout"/> is <see cref="System.Threading.Timeout.InfiniteTimeSpan"/>.</returns>
58+
[Obsolete("Use CancellationTokenMultiplexer class instead.")]
5659
public static CancellationTokenSource? LinkTo(this ref CancellationToken token, TimeSpan timeout)
5760
{
5861
CancellationTokenSource? result;
@@ -78,6 +81,7 @@ public static class LinkedTokenSourceFactory
7881
/// <param name="timeout">The timeout to link.</param>
7982
/// <param name="second">The second cancellation token.</param>
8083
/// <returns>The linked token source; or <see langword="null"/> if not needed.</returns>
84+
[Obsolete("Use CancellationTokenMultiplexer class instead.")]
8185
public static CancellationTokenSource? LinkTo(this ref CancellationToken first, TimeSpan timeout, CancellationToken second)
8286
{
8387
CancellationTokenSource? result;
@@ -114,6 +118,7 @@ public static bool CausedBy<TSource>(this OperationCanceledException e, TSource?
114118
where TSource : IMultiplexedCancellationTokenSource?
115119
=> source is null ? e.CancellationToken == token : e.CancellationToken == source.Token && source.CancellationOrigin == token;
116120

121+
[Obsolete]
117122
private sealed class MultipleLinkedCancellationTokenSource : LinkedCancellationTokenSource
118123
{
119124
private MemoryOwner<CancellationTokenRegistration> registrations;

0 commit comments

Comments
 (0)