Skip to content

Commit 5baf93e

Browse files
committed
Put AggressiveInline attribute similar to ValueTask.
1 parent 85bda1e commit 5baf93e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

CodeJam.Main/Threading/AwaitableNonDisposable.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
using JetBrains.Annotations;
88

9+
using static CodeJam.Targeting.MethodImplOptionsExt;
10+
911
namespace CodeJam.Threading
1012
{
1113
/// <summary>
@@ -25,6 +27,7 @@ public struct AwaitableNonDisposable<T> where T : IDisposable
2527
/// Initializes a new awaitable wrapper around the specified task.
2628
/// </summary>
2729
/// <param name="task">The underlying task to wrap. This may not be <c>null</c>.</param>
30+
[MethodImpl(AggressiveInlining)]
2831
public AwaitableNonDisposable([NotNull] Task<T> task)
2932
{
3033
Code.NotNull(task, nameof(task));
@@ -36,7 +39,7 @@ public AwaitableNonDisposable([NotNull] Task<T> task)
3639
/// Returns the underlying task.
3740
/// </summary>
3841
/// <returns>Underlying task.</returns>
39-
[NotNull]
42+
[NotNull][MethodImpl(AggressiveInlining)]
4043
public Task<T> AsTask()
4144
{
4245
return _task;
@@ -47,7 +50,7 @@ public Task<T> AsTask()
4750
/// </summary>
4851
/// <param name="source">The awaitable wrapper.</param>
4952
/// <returns>Underlying task</returns>
50-
[NotNull]
53+
[NotNull][MethodImpl(AggressiveInlining)]
5154
public static implicit operator Task<T>([NotNull] AwaitableNonDisposable<T> source)
5255
{
5356
return source.AsTask();
@@ -57,6 +60,7 @@ public static implicit operator Task<T>([NotNull] AwaitableNonDisposable<T> sour
5760
/// Infrastructure. Returns the task awaiter for the underlying task.
5861
/// </summary>
5962
/// <returns>Task awaiter for the underlying task.</returns>
63+
[MethodImpl(AggressiveInlining)]
6064
public TaskAwaiter<T> GetAwaiter()
6165
{
6266
return _task.GetAwaiter();
@@ -67,6 +71,7 @@ public TaskAwaiter<T> GetAwaiter()
6771
/// </summary>
6872
/// <param name="continueOnCapturedContext">Whether to attempt to marshal the continuation back to the captured context.</param>
6973
/// <returns>A configured task awaiter for the underlying task.</returns>
74+
[MethodImpl(AggressiveInlining)]
7075
public ConfiguredTaskAwaitable<T> ConfigureAwait(bool continueOnCapturedContext)
7176
{
7277
return _task.ConfigureAwait(continueOnCapturedContext);

0 commit comments

Comments
 (0)