Skip to content

Commit

Permalink
Ensures getAllCores returns a valid number (fixes issue #75)
Browse files Browse the repository at this point in the history
  • Loading branch information
Renaud committed Jan 17, 2017
1 parent d4eb958 commit 6996bce
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion R/utils.R
Expand Up @@ -46,7 +46,15 @@ rmAttributes <- function(x){
# returns total number of available cores
getAllCores <- function(){
isOpenBSD <- grepl('openbsd', R.version$os, ignore.case = TRUE)
parallel::detectCores(all.tests = isOpenBSD)
n <- parallel::detectCores(all.tests = isOpenBSD)
# try harder if not successful
if( is.na(n) ) n <- parallel::detectCores(all.tests = TRUE)
# make sure a valid value is returned (issue #75)
if( is.na(n) ){
warning("Could not determine total number of cores on host: using single core.")
n <- 1L
}
n
}

#' \code{str_args} formats the arguments of a function using \code{\link{args}},
Expand Down

0 comments on commit 6996bce

Please sign in to comment.