Use compute profiles to manage multiple daemon pools
mainYou can create independent pools of workers using the .compute argument. This allows you to separate workloads (e.g., CPU-bound vs GPU-bound tasks).
daemons(n, .compute = "name"): Creates a new compute profile.local_daemons("name"): Switches the active compute profile for the duration of the current function.with_daemons("name", { ... }): Switches the active compute profile for a specific block of code.
# Create independent pools
daemons(4, .compute = "cpu")
daemons(2, .compute = "gpu")
# Run tasks on specific profiles
m1 <- mirai(cpu_work(), .compute = "cpu")
m2 <- mirai(gpu_work(), .compute = "gpu")
# Switch active profile for a block
with_daemons("workers", {
m <- mirai(task())
m[]
})