Set or view the number of daemons (background processes). Create persistent background processes to receive mirai requests. This provides a potentially more efficient solution for async operations as new processes no longer need to be created on an ad hoc basis.




either an integer to set the number of daemons, or 'view' to view the number of currently active daemons.


Depending on the specified ... parameter:

  • integer: integer change in number of daemons (created or destroyed).

  • 'view': integer number of currently set daemons.

  • missing: the 'nanoSocket' for connecting to the daemons, or NULL if it is yet to be created.


{mirai} will revert to the default behaviour of creating a new background process for each request if the number of daemons is set to 0.

The current implementation is low-level and ensures tasks are evenly-distributed amongst daemons without actively managing a task queue. This approach provides a robust and resource-light solution, particularly well-suited to working with similar-length tasks, or where the number of concurrent tasks typically does not exceed the number of available daemons.


if (interactive()) {
# Only run examples in interactive R sessions

# Create 4 daemons
# View the number of active daemons
# Reset to zero