Commit 202f992
Add async sort variants: sortAsync, sortByAsync, sortDescendingAsync, sortByDescendingAsync, sortWithAsync
The existing sort functions (sort, sortBy, sortDescending, sortByDescending,
sortWith) use Async.RunSynchronously internally, which blocks a thread and
cannot be composed in async workflows without escaping to a thread-pool.
This PR adds five Async<'T[]>-returning counterparts for composing sort
operations inside async { ... } blocks:
AsyncSeq.sortAsync : AsyncSeq<'T> -> Async<'T[]>
AsyncSeq.sortByAsync : ('T -> 'Key) -> AsyncSeq<'T> -> Async<'T[]>
AsyncSeq.sortDescendingAsync : AsyncSeq<'T> -> Async<'T[]>
AsyncSeq.sortByDescendingAsync: ('T -> 'Key) -> AsyncSeq<'T> -> Async<'T[]>
AsyncSeq.sortWithAsync : ('T -> 'T -> int) -> AsyncSeq<'T> -> Async<'T[]>
Each is a thin wrapper over toArrayAsync + Async.map, identical semantics to
the sync counterparts but composable without blocking. 6 new tests added;
all 378 existing tests continue to pass.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 6be414a commit 202f992
File tree
4 files changed
+84
-0
lines changed- src/FSharp.Control.AsyncSeq
- tests/FSharp.Control.AsyncSeq.Tests
4 files changed
+84
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
1 | 9 | | |
2 | 10 | | |
3 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2244 | 2244 | | |
2245 | 2245 | | |
2246 | 2246 | | |
| 2247 | + | |
| 2248 | + | |
| 2249 | + | |
| 2250 | + | |
| 2251 | + | |
| 2252 | + | |
| 2253 | + | |
| 2254 | + | |
| 2255 | + | |
| 2256 | + | |
| 2257 | + | |
| 2258 | + | |
| 2259 | + | |
| 2260 | + | |
| 2261 | + | |
2247 | 2262 | | |
2248 | 2263 | | |
2249 | 2264 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
730 | 730 | | |
731 | 731 | | |
732 | 732 | | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
733 | 753 | | |
734 | 754 | | |
735 | 755 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3456 | 3456 | | |
3457 | 3457 | | |
3458 | 3458 | | |
| 3459 | + | |
| 3460 | + | |
| 3461 | + | |
| 3462 | + | |
| 3463 | + | |
| 3464 | + | |
| 3465 | + | |
| 3466 | + | |
| 3467 | + | |
| 3468 | + | |
| 3469 | + | |
| 3470 | + | |
| 3471 | + | |
| 3472 | + | |
| 3473 | + | |
| 3474 | + | |
| 3475 | + | |
| 3476 | + | |
| 3477 | + | |
| 3478 | + | |
| 3479 | + | |
| 3480 | + | |
| 3481 | + | |
| 3482 | + | |
| 3483 | + | |
| 3484 | + | |
| 3485 | + | |
| 3486 | + | |
| 3487 | + | |
| 3488 | + | |
| 3489 | + | |
| 3490 | + | |
| 3491 | + | |
| 3492 | + | |
| 3493 | + | |
| 3494 | + | |
| 3495 | + | |
| 3496 | + | |
| 3497 | + | |
| 3498 | + | |
| 3499 | + | |
3459 | 3500 | | |
3460 | 3501 | | |
3461 | 3502 | | |
| |||
0 commit comments