Repository navigation
Conversation
… D164)
`with_concurrency(tasks, n)` documented "at most n tasks at a time" and
its body was `let _ = n; tasks` (lib/std/task.w:227-230); the call did
not even compile ("return type mismatch" inside task.w). No
task-taking signature can mean what the doc said: a Task is already
running (§24.1). Measured on the task-taking draft, `ids |> map(f)`
started all 6 tasks under limits 2 and 1, and the lazy adapter spelling
does not type-check into `impl IntoIter[Task[T]]`.
`with_concurrency[I, T](inputs: impl IntoIter[I], n: isize, f: fn(I) -> Task[T]) -> List[T]`
runs `f` over the inputs, calling `f(input)` — which spawns (#2748) —
only when a slot frees, and returns results in input order. `n < 1` is
the same loud refusal `await_first` gives empty input. Docs follow:
lib/std/async/with_concurrency.md, lib/std/async/README.md, and the
migration guide's `ids |> map(fetch_user) |> with_concurrency(10) |> await_all`
becomes `ids |> with_concurrency(10, fetch_user)`.
Test behav_981_with_concurrency_bounds_running_tasks (fails pre-fix:
"expects 2 argument(s), found 3"): squares of [6..1] in input order,
peak 2 running under limit 2, peak 1 under limit 1, empty input empty;
debug allocator leak count=0. Delegated under D98 as D164 (80%).
Ceremony found, not fixed here: an unannotated list literal through an
ordinary generic call binds its isize default before a later fn
argument's demand (`map` takes the demand; `with_concurrency` does
not), so the fixture annotates `List[i32]`.
Contributor
Author
|
Battery GREEN on the stack top |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
std.task: with_concurrency starts the work itself and bounds it (#981, D164)
with_concurrency(tasks, n)documented "at most n tasks at a time" andits body was
let _ = n; tasks(lib/std/task.w:227-230); the call didnot even compile ("return type mismatch" inside task.w). No
task-taking signature can mean what the doc said: a Task is already
running (§24.1). Measured on the task-taking draft,
ids |> map(f)started all 6 tasks under limits 2 and 1, and the lazy adapter spelling
does not type-check into
impl IntoIter[Task[T]].with_concurrency[I, T](inputs: impl IntoIter[I], n: isize, f: fn(I) -> Task[T]) -> List[T]runs
fover the inputs, callingf(input)— which spawns (#2748) —only when a slot frees, and returns results in input order.
n < 1isthe same loud refusal
await_firstgives empty input. Docs follow:lib/std/async/with_concurrency.md, lib/std/async/README.md, and the
migration guide's
ids |> map(fetch_user) |> with_concurrency(10) |> await_allbecomes
ids |> with_concurrency(10, fetch_user).Test behav_981_with_concurrency_bounds_running_tasks (fails pre-fix:
"expects 2 argument(s), found 3"): squares of [6..1] in input order,
peak 2 running under limit 2, peak 1 under limit 1, empty input empty;
debug allocator leak count=0. Delegated under D98 as D164 (80%).
Ceremony found, not fixed here: an unannotated list literal through an
ordinary generic call binds its isize default before a later fn
argument's demand (
maptakes the demand;with_concurrencydoesnot), so the fixture annotates
List[i32].