Skip to content

Commit

Permalink
adds nextcode()
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Jan 11, 2025
1 parent b5330c0 commit c0d6ecd
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export(local_url)
export(make_cluster)
export(mirai)
export(mirai_map)
export(nextcode)
export(nextget)
export(nextstream)
export(register_cluster)
Expand Down
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

#### Updates

* `daemon()` now returns an integer exit value to indicate the reason for termination.
* `daemon()` now returns an integer exit code to indicate the reason for termination.
* Adds `nextcode()` to provide a human-readable translation of the exit codes returned by `daemon()`.

# mirai 2.0.0

Expand Down
28 changes: 28 additions & 0 deletions R/next.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,34 @@ nextstream <- function(.compute = "default") next_stream(..[[.compute]])
#'
nextget <- function(x, .compute = "default") ..[[.compute]][[x]]

#' Next >> Developer Interface
#'
#' \code{nextcode} translates integer exit codes returned by
#' \code{\link{daemon}}.
#'
#' @param xc integer value.
#'
#' @return For \code{nextcode}: character string.
#'
#' @examples
#' nextcode(0L)
#' nextcode(1L)
#'
#' @keywords internal
#' @rdname nextstream
#' @export
#'
nextcode <- function(xc) {
str <- switch(xc + 1L,
"0 | Daemon connection terminated",
"1 | Daemon idletime limit reached",
"2 | Daemon walltime limit reached",
"3 | Daemon task limit reached"
)
is.null(str) && return("")
str
}

# internals --------------------------------------------------------------------

next_stream <- function(envir) {
Expand Down
13 changes: 13 additions & 0 deletions man/nextstream.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c0d6ecd

Please sign in to comment.