Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce some allocations with the magic of spans etc. #5938

merged 7 commits into from May 5, 2021
Changes from 1 commit
File filter
Filter file types
Failed to load comments.
Jump to
Jump to file
Failed to load files.


Just for now

prevent cancellationtoken leakage
  • Loading branch information
cvium committed Apr 30, 2021
commit ba2e346d1246cc51e186a64d38a9b7385492ca4f
@@ -661,7 +661,9 @@ public async Task<List<TunerHostInfo>> DiscoverDevices(int discoveryDurationMs,

cancellationToken = CancellationTokenSource.CreateLinkedTokenSource(new CancellationTokenSource(discoveryDurationMs).Token, cancellationToken).Token;
using var timedCancellationToken = new CancellationTokenSource(discoveryDurationMs);
using var linkedCancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(timedCancellationToken.Token, cancellationToken);
cancellationToken = linkedCancellationTokenSource.Token;
var list = new List<TunerHostInfo>();

// Create udp broadcast discovery message
@@ -150,7 +150,8 @@ protected virtual List<string> GetStreamFilePaths()

public async Task CopyToAsync(Stream stream, CancellationToken cancellationToken)
cancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, LiveStreamCancellationTokenSource.Token).Token;
using var linkedCancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, LiveStreamCancellationTokenSource.Token);
cancellationToken = linkedCancellationTokenSource.Token;

// use non-async filestream on windows along with read due to
var allowAsync = Environment.OSVersion.Platform != PlatformID.Win32NT;
@@ -71,7 +71,8 @@ public ProgressiveFileCopier(IDirectStreamProvider directStreamProvider, Transco
/// <returns>A <see cref="Task"/>.</returns>
public async Task WriteToAsync(Stream outputStream, CancellationToken cancellationToken)
cancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, _cancellationToken).Token;
using var linkedCancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, _cancellationToken);
cancellationToken = linkedCancellationTokenSource.Token;

ProTip! Use n and p to navigate between commits in a pull request.