mizu_submit_batch() submits one task per element of .exprs in a
single .Call: one crossing into shared memory and one wake-up sweep
per batch instead of per task. At high task rates the cost of each R
call matters, so a burst submitted this way reaches the workers
sooner than the same burst looped through mizu_submit(). Pair with
mizu_collect_all() to batch the collection side too.
Arguments
- .pool
a pool handle from
mizu_pool()ormizu_pool_attach(); inside a task, the evaluating worker's own handle frommizu_current_pool().- .exprs
a list of expressions, one per task. Quote them yourself: elements of a list cannot be captured unevaluated.
- ...
named values bound in the evaluation environment. The values are serialized.
mori::share()d objects reduce to identifiers and map zero-copy on the worker. The formals ahead of...are dot-prefixed, so a name you pass through...can never collide with them.- .timeout
seconds to wait for injection-ring space before the call raises
mizu_error_submit_timeout. Submission blocks only when the ring is full (back-pressure) and returns immediately otherwise.Inf(the default) waits indefinitely;0does not wait.
Value
A list of task handles (class "mizu_task"), one per accepted task.
The list is shorter than .exprs when the ring filled past .timeout
mid-batch.
Details
Each task's wire payload is the same list(.expr, args) as
mizu_submit()'s, with the ... arguments shared by every task in
the batch. Unlike mizu_submit(), expressions are not captured:
the elements of .exprs are pre-quoted (or plain values, which
evaluate to themselves).
Submission behaves per task as in mizu_submit(), with one difference: if
the injection ring fills past .timeout mid-batch, the call returns the
handles accepted so far instead of raising mizu_error_submit_timeout. Fatal
outcomes (pool stopped, result slots exhausted) still raise, and tasks
already submitted stay valid and collectible.
Examples
p <- mizu_pool()
ts <- mizu_submit_batch(p, list(quote(1 + 1), quote(2 + 2)))
mizu_collect_all(ts, timeout = 30)
#> [[1]]
#> [1] 2
#>
#> [[2]]
#> [1] 4
#>
mizu_pool_stop(p)