forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Channel.CreateUnboundedPrioritized (dotnet#100550)
- Loading branch information
1 parent
d02647a
commit a90e4b7
Showing
11 changed files
with
587 additions
and
31 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
17 changes: 17 additions & 0 deletions
17
src/libraries/System.Threading.Channels/ref/System.Threading.Channels.netstandard21.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,17 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// ------------------------------------------------------------------------------ | ||
// Changes to this file must follow the https://aka.ms/api-review process. | ||
// ------------------------------------------------------------------------------ | ||
|
||
namespace System.Threading.Channels | ||
{ | ||
public partial class ChannelClosedException : System.InvalidOperationException | ||
{ | ||
#if NET8_0_OR_GREATER | ||
[System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] | ||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] | ||
#endif | ||
protected ChannelClosedException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } | ||
} | ||
} |
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
36 changes: 36 additions & 0 deletions
36
src/libraries/System.Threading.Channels/src/System/Threading/Channels/Channel.netcoreapp.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,36 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace System.Threading.Channels | ||
{ | ||
/// <summary>Provides static methods for creating channels.</summary> | ||
public static partial class Channel | ||
{ | ||
/// <summary>Creates an unbounded prioritized channel usable by any number of readers and writers concurrently.</summary> | ||
/// <returns>The created channel.</returns> | ||
/// <remarks> | ||
/// <see cref="Comparer{T}.Default"/> is used to determine priority of elements. | ||
/// The next item read from the channel will be the element available in the channel with the lowest priority value. | ||
/// </remarks> | ||
public static Channel<T> CreateUnboundedPrioritized<T>() => | ||
new UnboundedPrioritizedChannel<T>(runContinuationsAsynchronously: true, comparer: null); | ||
|
||
/// <summary>Creates an unbounded prioritized channel subject to the provided options.</summary> | ||
/// <typeparam name="T">Specifies the type of data in the channel.</typeparam> | ||
/// <param name="options">Options that guide the behavior of the channel.</param> | ||
/// <returns>The created channel.</returns> | ||
/// <remarks> | ||
/// The supplied <paramref name="options"/>' <see cref="UnboundedPrioritizedChannelOptions{T}.Comparer"/> is used to determine priority of elements, | ||
/// or <see cref="Comparer{T}.Default"/> if the provided comparer is null. | ||
/// The next item read from the channel will be the element available in the channel with the lowest priority value. | ||
/// </remarks> | ||
public static Channel<T> CreateUnboundedPrioritized<T>(UnboundedPrioritizedChannelOptions<T> options) | ||
{ | ||
ArgumentNullException.ThrowIfNull(options); | ||
|
||
return new UnboundedPrioritizedChannel<T>(!options.AllowSynchronousContinuations, options.Comparer); | ||
} | ||
} | ||
} |
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
14 changes: 14 additions & 0 deletions
14
...ries/System.Threading.Channels/src/System/Threading/Channels/ChannelOptions.netcoreapp.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,14 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace System.Threading.Channels | ||
{ | ||
/// <summary>Provides options that control the behavior of instances created by <see cref="M:Channel.CreateUnboundedPrioritized"/>.</summary> | ||
public sealed class UnboundedPrioritizedChannelOptions<T> : ChannelOptions | ||
{ | ||
/// <summary>Gets or sets the comparer used by the channel to prioritize elements.</summary> | ||
public IComparer<T>? Comparer { get; set; } | ||
} | ||
} |
Oops, something went wrong.