Skip to content

Commit

Permalink
streamline daemons()
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Nov 9, 2023
1 parent 1c7e5d4 commit dadc064
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# mirai 0.11.1.9000 (development)

* Fixes regression in 0.11.1 which prevented the correct random seed being set when using dispatcher.
* Internal performance enhancements.

# mirai 0.11.1
Expand Down
11 changes: 5 additions & 6 deletions R/daemons.R
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,11 @@ daemons <- function(n, url = NULL, remote = NULL, dispatcher = TRUE, ...,
missing(n) && missing(url) && return(status(.compute))

envir <- ..[[.compute]]
if (is.null(envir))
envir <- new.env(hash = FALSE, parent = ..)

if (is.character(url)) {

if (!length(envir)) {
if (is.null(envir)) {
envir <- new.env(hash = FALSE, parent = ..)
purl <- parse_url(url)
if (substr(purl[["scheme"]], 1L, 3L) %in% c("wss", "tls") && is.null(tls)) {
tls <- write_cert(cn = purl[["hostname"]])
Expand Down Expand Up @@ -354,9 +353,10 @@ daemons <- function(n, url = NULL, remote = NULL, dispatcher = TRUE, ...,
length(envir[["sockc"]]) && reap(envir[["sockc"]])
..[[.compute]] <- NULL -> envir

} else if (!length(envir)) {
} else if (is.null(envir)) {

n > 0L || stop(.messages[["n_zero"]])
envir <- new.env(hash = FALSE, parent = ..)
urld <- auto_tokenized_url()
cv <- cv()
create_stream(n = n, seed = seed, envir = envir)
Expand All @@ -383,8 +383,7 @@ daemons <- function(n, url = NULL, remote = NULL, dispatcher = TRUE, ...,

}

n <- envir[["n"]]
if (is.null(n)) 0L else if (!n) urls else n
if (is.null(envir)) 0L else if (envir[["n"]]) envir[["n"]] else envir[["urls"]]

}

Expand Down

0 comments on commit dadc064

Please sign in to comment.