diff --git a/R/later.R b/R/later.R index 886c240e..ffa15095 100644 --- a/R/later.R +++ b/R/later.R @@ -104,7 +104,7 @@ create_loop <- function(parent = current_loop(), autorun = NULL) { lockBinding("id", loop) # Add a weak reference to the loop object in our registry. - .loops[[sprintf("%d", id)]] <- new_weakref(loop) + .loops[[as.character(id)]] <- new_weakref(loop) if (id != 0L) { # Inform the C++ layer that there are no more R references when the handle @@ -126,7 +126,7 @@ notify_r_ref_deleted <- function(loop) { res <- notifyRRefDeleted(loop$id) if (res) { - rm(list = sprintf("%d", loop$id), envir = .loops) + rm(list = as.character(loop$id), envir = .loops) } invisible(res) } @@ -140,7 +140,7 @@ destroy_loop <- function(loop) { res <- deleteCallbackRegistry(loop$id) if (res) { - rm(list = sprintf("%d", loop$id), envir = .loops) + rm(list = as.character(loop$id), envir = .loops) } invisible(res) } @@ -155,7 +155,7 @@ exists_loop <- function(loop) { #' @export current_loop <- function() { id <- getCurrentRegistryId() - loop_weakref <- .loops[[sprintf("%d", id)]] + loop_weakref <- .loops[[as.character(id)]] if (is.null(loop_weakref)) { stop("Current loop with id ", id, " not found.") } diff --git a/inst/include/later.h b/inst/include/later.h index f935e048..f767e152 100644 --- a/inst/include/later.h +++ b/inst/include/later.h @@ -141,7 +141,7 @@ class BackgroundTask { pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_t t; - pthread_create(&t, NULL, BackgroundTask::task_main, this); + pthread_create(&t, &attr, BackgroundTask::task_main, this); pthread_attr_destroy(&attr); #else HANDLE hThread = ::CreateThread( diff --git a/src/Makevars.in b/src/Makevars.in index f466648c..f7be559a 100644 --- a/src/Makevars.in +++ b/src/Makevars.in @@ -1,4 +1,4 @@ -PKG_CPPFLAGS = -pthread -DSTRICT_R_HEADERS @pkg_cppflags@ +PKG_CPPFLAGS = -pthread -DSTRICT_R_HEADERS -DRCPP_NO_MODULES @pkg_cppflags@ PKG_LIBS = -pthread @extra_pkg_libs@ #### Debugging flags #### diff --git a/src/Makevars.win b/src/Makevars.win index c0ecc8ae..869cd320 100644 --- a/src/Makevars.win +++ b/src/Makevars.win @@ -1,4 +1,4 @@ -PKG_CPPFLAGS = -DSTRICT_R_HEADERS +PKG_CPPFLAGS = -DSTRICT_R_HEADERS -DRCPP_NO_MODULES PKG_LIBS = -lWs2_32 #### Debugging flags #### diff --git a/src/later_posix.cpp b/src/later_posix.cpp index dae77c0d..2741ef3a 100644 --- a/src/later_posix.cpp +++ b/src/later_posix.cpp @@ -55,9 +55,7 @@ void set_fd(bool ready) { hot = true; } else { if (read(pipe_out, buf, BUF_SIZE) < 0) { - // TODO: This sets a warning but it doesn't get displayed until - // after the next R command is executed. Can we make it sooner? - Rf_warning("Failed to read out of pipe for later package"); + Rf_warningcall_immediate(R_NilValue, "Failed to read out of pipe for later package"); } hot = false; }