Skip to content

Broadcasts shutdown, wakes every sleeping participant, and cancels all pending tasks (blocked collectors raise mizu_error_cancelled). Then waits up to timeout seconds for the workers to exit cleanly, and deletes the shared region and the liveness files. The handle is dead afterwards, and stopping it again does nothing. Only the creating process can stop a pool.

Usage

mizu_pool_stop(pool, timeout = 5)

Arguments

pool

a pool handle from mizu_pool() or mizu_pool_attach(); inside a task, the evaluating worker's own handle from mizu_current_pool().

timeout

seconds to wait for the clean exit of the workers.

Value

Invisibly, TRUE if all workers exited within the timeout. FALSE otherwise, with a warning (the workers still exit on their own).

Details

A stop also rejects every promise still pending on the pool (task promises, mizu_collect_all_async() and mizu_collect_any_async() collections, and map promises) with mizu_error_stopped.

Examples

p <- mizu_pool()
t <- mizu_submit(p, 1 + 1)
mizu_collect(t)
#> [1] 2
mizu_pool_stop(p)