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

Remove allocation of state machine in QuicStream.WriteAsync #103902

Merged
merged 5 commits into from
Jun 26, 2024
Merged
Changes from 3 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
10 changes: 4 additions & 6 deletions src/libraries/System.Net.Quic/src/System/Net/Quic/QuicStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationTo
/// <param name="buffer">The region of memory to write data from.</param>
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None"/>.</param>
/// <param name="completeWrites">Notifies the peer about gracefully closing the write side, i.e.: sends FIN flag with the data.</param>
public async ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, bool completeWrites, CancellationToken cancellationToken = default)
public ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, bool completeWrites, CancellationToken cancellationToken = default)
rzikm marked this conversation as resolved.
Show resolved Hide resolved
{
ObjectDisposedException.ThrowIf(_disposed == 1, this);

Expand Down Expand Up @@ -379,8 +379,7 @@ public async ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, bool completeWrit
// No need to call anything since we already have a result, most likely an exception.
if (valueTask.IsCompleted)
{
await valueTask.ConfigureAwait(false);
return;
return valueTask;
}

// For an empty buffer complete immediately, close the writing side of the stream if necessary.
Expand All @@ -391,8 +390,7 @@ public async ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, bool completeWrit
{
CompleteWrites();
}
await valueTask.ConfigureAwait(false);
return;
return valueTask;
}

// We own the lock, abort might happen, but exception will get stored instead.
Expand Down Expand Up @@ -428,7 +426,7 @@ public async ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, bool completeWrit
}
}

await valueTask.ConfigureAwait(false);
return valueTask;
}

/// <summary>
Expand Down
Loading