-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Compile runtime async versions of synchronous task-returning methods #128384
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
base: main
Are you sure you want to change the base?
Changes from all commits
192f7ba
74aab70
5cec9e3
27470b8
9572940
514d583
13c2045
26c12f9
1cbeb65
e4f192a
560d57c
a84f1f9
b408bbb
c8c51bd
98fbcd6
9171266
3c75d0c
c641a27
9a83488
66ce9bc
9bd789b
ec9ac48
8a699d2
8a56ec2
c94a1e7
f90af75
26dfa36
b6c8df0
d1e9b6f
6608440
a51ee2c
cb72b1f
95a22ef
9fce751
3821f20
d2478b7
d868fa1
d30d682
7d68aed
9fc801c
2ab7e7e
0210e2a
bb0cd7e
4cd1798
61f16ee
ab9a2a8
4292f8a
002e41d
f906f72
09aada0
e680b74
0810b96
f6f0e83
8b92f62
b10ff69
058d5d0
ccebf1b
40bc90f
f018bdc
bdb00ea
8e4bf6f
1e601d7
cb429d9
8d3b9ea
815f100
144a6f7
3c5235a
12bfb2d
65d1b97
d74ec56
4ec6f1e
ccbe3b0
50d03de
a09e258
b1d26ba
17e1f34
f41ad6e
aaaa3c6
69aef66
d8b3b2c
d1c9c43
40cf410
7a04e3f
71badf6
42c8f00
f0f0713
081ac5e
9758ec6
d6dff98
b3f4d04
dc63e63
62112be
44438da
3b97fed
3e5dfce
15b4d4c
4801b0f
a0bb532
28cb713
2a95de7
9c92609
d318b19
749edf3
ac0ef8b
a823331
d2487cd
1168f58
54c8b3f
cae23c4
933b4bb
72deed0
0525eeb
45ef235
434e48e
5a3aa05
673f235
e769d56
35fa1ca
4507c16
a79a09a
5fedf9d
3d1d8ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -664,6 +664,61 @@ private static unsafe T TransparentAwaitOfT<T>(Task<T> task) | |
| return default!; | ||
| } | ||
|
|
||
| [BypassReadyToRun] | ||
| [MethodImpl(MethodImplOptions.Async)] | ||
| private static void TransparentAwaitWithResult(Task task) | ||
| { | ||
| if (!task.IsCompleted) | ||
| { | ||
| TailAwait(); | ||
| TransparentAwait(task); | ||
| return; | ||
| } | ||
|
|
||
| TaskAwaiter.ValidateEnd(task); | ||
| } | ||
|
|
||
| [BypassReadyToRun] | ||
| [MethodImpl(MethodImplOptions.Async)] | ||
| private static void TransparentAwaitWithResult(ValueTask task) | ||
| { | ||
| if (!task.IsCompleted) | ||
| { | ||
| TailAwait(); | ||
| TransparentAwaitValueTask(task); | ||
| return; | ||
| } | ||
|
|
||
| task.ThrowIfCompletedUnsuccessfully(); | ||
| } | ||
|
|
||
| [BypassReadyToRun] | ||
| [MethodImpl(MethodImplOptions.Async)] | ||
| private static T TransparentAwaitWithResult<T>(Task<T> task) | ||
| { | ||
| if (!task.IsCompleted) | ||
| { | ||
| TailAwait(); | ||
| return TransparentAwaitOfT(task); | ||
| } | ||
|
|
||
| TaskAwaiter.ValidateEnd(task); | ||
| return task.ResultOnSuccess; | ||
| } | ||
|
|
||
| [BypassReadyToRun] | ||
| [MethodImpl(MethodImplOptions.Async)] | ||
| private static T TransparentAwaitWithResult<T>(ValueTask<T> task) | ||
| { | ||
| if (!task.IsCompleted) | ||
| { | ||
| TailAwait(); | ||
| return TransparentAwaitValueTaskOfT(task); | ||
| } | ||
|
|
||
| return task.Result; | ||
| } | ||
|
Comment on lines
+711
to
+720
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I want to rename these in a follow-up -- we have
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another possible naming for the existing helpers is |
||
|
|
||
| // Represents execution of a chain of suspended and resuming runtime | ||
| // async functions. | ||
| private sealed class RuntimeAsyncTask<T> : Task<T> | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.