-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged PR 3115: Wait to Complete Pipe
Fixed the `PipeWriterStream` to properly detect a canceled write and throw an `OperationCanceledException` in those cases. And making sure `Complete` is called in a safe manner by ensuring it is in a lock so writes can't be in-progress.
- Loading branch information
1 parent
f198e55
commit 7fd42c4
Showing
8 changed files
with
164 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/SignalR/common/Http.Connections/src/Internal/TaskExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Runtime.CompilerServices; | ||
|
||
namespace System.Threading.Tasks | ||
{ | ||
internal static class TaskExtensions | ||
{ | ||
public static async Task NoThrow(this Task task) | ||
{ | ||
await new NoThrowAwaiter(task); | ||
} | ||
} | ||
|
||
internal readonly struct NoThrowAwaiter : ICriticalNotifyCompletion | ||
{ | ||
private readonly Task _task; | ||
public NoThrowAwaiter(Task task) { _task = task; } | ||
public NoThrowAwaiter GetAwaiter() => this; | ||
public bool IsCompleted => _task.IsCompleted; | ||
// Observe exception | ||
public void GetResult() { _ = _task.Exception; } | ||
public void OnCompleted(Action continuation) => _task.GetAwaiter().OnCompleted(continuation); | ||
public void UnsafeOnCompleted(Action continuation) => OnCompleted(continuation); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters