This section provides comprehensive reference material for the mirai package, including the complete function interface, version history, and development information. It serves as a technical lookup resource for package functionality, organized by functional area and purpose.
For conceptual explanations and usage patterns, see the earlier sections: Core Functionality covers the primary evaluation and daemon management APIs, Distributed Computing explains deployment strategies, and Integration and Interoperability documents ecosystem integration. For detailed version-specific information and migration guides, see Version History and Changelog.
The mirai package exports 40 functions and operators, organized into nine functional areas. This structure reflects the layered architecture described in Architecture and Design Philosophy.
Sources: NAMESPACE1-111
| Category | Functions | Primary Purpose |
|---|---|---|
| Async Evaluation | mirai(), mirai_map(), race_mirai() | Create asynchronous computations |
| Result Access | call_mirai(), collect_mirai(), [] | Retrieve mirai values |
| Daemon Control | daemons(), daemon(), dispatcher() | Configure worker processes |
| Local Launch | launch_local() | Spawn daemons on local machine |
| Remote Launch | launch_remote(), cluster_config(), ssh_config(), remote_config() | Deploy daemons to remote resources |
| Monitoring | status(), info() | Observe system state |
| Broadcasting | everywhere() | Execute on all daemons |
| Profile Scoping | with_daemons(), local_daemons(), with() | Manage compute profiles |
| Error Handling | is_error_value(), is_mirai_error(), is_mirai_interrupt(), stop_mirai(), unresolved() | Detect and handle errors |
| Serialization | serial_config(), register_serial() | Custom object transfer |
| URL Construction | host_url(), local_url() | Generate connection URLs |
| Cluster Backend | make_cluster(), stop_cluster() | Create miraiCluster objects |
| Developer Tools | nextget(), nextstream(), nextcode(), on_daemon(), daemons_set(), require_daemons() | Package extension interfaces |
| Type Checking | is_mirai(), is_mirai_map() | Object type validation |
Sources: NAMESPACE28-64
The mirai package defines seven primary object classes with associated S3 methods. Understanding these types is essential for working with the package programmatically.
Sources: NAMESPACE3-24
A mirai object is an environment containing:
$data: The resolved value or an 'unresolvedValue' sentinel$id: Integer identifier, monotonically increasing per session"class": c("mirai", "recvAio")The object inherits from recvAio (nanonext package), enabling integration with nanonext's async I/O system.
Sources: NEWS.md46
A miraiError preserves complete error context:
$message: Character string error message$call: The call that generated the error (srcref stripped)$stack.trace: List of call objects without deparsing$condition.class: Original condition classes from errorrlang::abort() accessible via $Sources: NEWS.md51-53 NEWS.md175 NEWS.md210
The miraiCluster class implements the parallel package interface (R >= 4.4):
c("miraiCluster", "cluster")miraiNode objectsparallel::recvData(), parallel::sendData(), parallel::recvOneData(), parallel::stopCluster()<FileRef file-url="https://github.com/r-lib/mirai/blob/128718db/ returns plain list (not miraiCluster)\n\nSources#LNaN-LNaN" NaN file-path="` returns plain list (not miraiCluster)\n\nSources">Hii NEWS.md149-151 NEWS.md328The package defines 24 S3 methods across 11 generic functions. This enables seamless integration with base R, parallel, and promises ecosystems.
Sources: NAMESPACE3-24
The [ operator provides efficient collection for mirai objects:
| Usage | Behavior | Equivalent To |
|---|---|---|
m[] | Block until resolved, return $data | collect_mirai(m) |
m_map[] | Collect all mirai in map | collect_mirai(m_map) |
m_map[.progress] | Collect with progress bar | collect_mirai(m_map, "progress") |
m_map[.stop] | Early stop on first error | collect_mirai(m_map, "stop") |
m_map[.flat] | Flatten results list | collect_mirai(m_map, "flat") |
clust[i] | Extract subset (plain list) | Normal list subsetting |
Sources: NAMESPACE4-6 NEWS.md302
The package exports 49 symbols and imports 46 functions from nanonext, its only dependency beyond base R packages.
Sources: NAMESPACE65-111
The 40 exported symbols break down as:
mirai, mirai_map, race_mirai, call_mirai, collect_mirai, daemons, daemon, dispatcher, everywhere, launch_local, launch_remote, status, info, stop_mirai, unresolved)cluster_config, ssh_config, remote_config, host_url, local_url, make_cluster)is_error_value, is_mirai, is_mirai_error, is_mirai_interrupt, is_mirai_map, on_daemon, daemons_set)with_daemons, local_daemons, stop_cluster, require_daemons)nextget, nextstream, nextcode)serial_config, register_serial).flat, .progress, .stop)Sources: NAMESPACE25-64
The mirai_map collection system uses symbol objects to specify options. These are exported constants that enable readable collection syntax.
| Symbol | Type | Purpose | Behavior |
|---|---|---|---|
.flat | miraiCollectFlag | Flatten results | Avoids coercion when combining heterogeneous types |
.progress | miraiCollectFlag | Progress indication | Shows text progress bar or cli progress (if available) |
.stop | miraiCollectFlag | Early stopping | Returns on first error, cancels remaining tasks |
Collection options can be combined: m_map[.stop, .progress] collects with early stopping and progress display.
Sources: NAMESPACE25-27 NEWS.md259
The package maintains semantic versioning aligned with its primary dependency:
Major architectural changes occurred at:
info() function, compute profile helpersThe current development version includes:
For detailed version history and migration guidance, see Version History and Changelog.
Sources: NEWS.md1-7 NEWS.md8-19 NEWS.md28 NEWS.md44-82 NEWS.md233 NEWS.md330
The package provides three functions specifically for extension developers:
Retrieves internal state for daemon processes. Previously supported queries:
nextget("cv"): Returns the condition variable for signalingnextget("stream"): Returns the current L'Ecuyer-CMRG RNG streamNote: nextget("pid") was removed in mirai 2.5.1.
Sources: NEWS.md23-36 NEWS.md444
Returns the next L'Ecuyer-CMRG random seed for a given compute profile. Used internally by dispatchers to distribute RNG streams.
Sources: NEWS.md444
Translates integer exit codes from daemon() into human-readable explanations. Exit codes indicate termination reason (normal, timeout, task limit, etc.).
Sources: NEWS.md194
Prompts users to set up daemons if not already configured. Provides clickable function link when cli package is available.
Signature: require_daemons(.compute, call)
Note: Returns invisibly as intended (fixed in 2.5.2). Argument order was previously (call, .compute) but swapped in 2.5.0 for ease of use.
Sources: NEWS.md8-19 NEWS.md59-74 NEWS.md103-117
For information on the testing framework, continuous integration workflows, and contribution guidelines, see Testing and Development.
For complete function signatures and detailed parameter documentation, see Function Reference.
Refresh this wiki
This wiki was recently refreshed. Please wait 4 days to refresh again.