From 85d99db5f390af5df211101fa83ce256bb16ba95 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 5 Oct 2026 09:12:04 -0500 Subject: run continuations async --- src/slskd/Common/TokenBucket.cs | 4 ++-- src/slskd/Transfers/Downloads/DownloadService.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/slskd/Common/TokenBucket.cs b/src/slskd/Common/TokenBucket.cs index 11d64b88..440f25ae 100644 --- a/src/slskd/Common/TokenBucket.cs +++ b/src/slskd/Common/TokenBucket.cs @@ -92,7 +92,7 @@ namespace slskd /// public class TokenBucket : ITokenBucket, IDisposable { - private TaskCompletionSource waitForReset = new(); + private TaskCompletionSource waitForReset = new(TaskCreationOptions.RunContinuationsAsynchronously); /// /// Initializes a new instance of the class. @@ -243,6 +243,6 @@ namespace slskd } private void Reset() - => Interlocked.Exchange(ref waitForReset, new TaskCompletionSource()).SetResult(true); + => Interlocked.Exchange(ref waitForReset, new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously)).SetResult(true); } } diff --git a/src/slskd/Transfers/Downloads/DownloadService.cs b/src/slskd/Transfers/Downloads/DownloadService.cs index 30f3c9b1..cb9423bc 100644 --- a/src/slskd/Transfers/Downloads/DownloadService.cs +++ b/src/slskd/Transfers/Downloads/DownloadService.cs @@ -509,7 +509,7 @@ namespace slskd.Transfers.Downloads add this to the dictionary before inserting the record, so we are guaranteed to have it in the right place once the transfer hits the UI */ - var enqueuedTcs = new TaskCompletionSource(); + var enqueuedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); // satisfies condition #3; CancellationTokenSource set cancelled by the user (via API call) var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); -- cgit v1.2.3