Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions 17 src/DotNext.Tests/Threading/CancellationTokenMultiplexerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,23 @@ public static void CheckPooling()
}
}

[Fact]
public async Task CheckPoolingNonInterference()
{
var multiplexer = new CancellationTokenMultiplexer();

using var cts = new CancellationTokenSource();

await multiplexer.Combine([cts.Token, cts.Token, cts.Token]).DisposeAsync();

// same source is reused from pool, but should now not be associated with cts.
await using var combined = multiplexer.Combine([new(), new(), new()]);

cts.Cancel();

False(combined.Token.IsCancellationRequested);
}

[Fact]
public static void ExtraListOverflow()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private void Add(CancellationTokenRegistration registration)
private ref CancellationTokenRegistration FirstInlinedRegistration
=> ref Unsafe.As<InlinedTokenList, CancellationTokenRegistration>(ref inlinedList);

public int Count => inlinedTokenCount + extraTokens?.Count ?? 0;
public int Count => inlinedTokenCount + (extraTokens?.Count ?? 0);

public ref CancellationTokenRegistration this[int index]
{
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.