Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some small improvements #193

Merged
merged 4 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions R/later.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
Expand All @@ -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)
}
Expand All @@ -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.")
}
Expand Down
2 changes: 1 addition & 1 deletion inst/include/later.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/Makevars.in
Original file line number Diff line number Diff line change
@@ -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 ####
Expand Down
2 changes: 1 addition & 1 deletion src/Makevars.win
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PKG_CPPFLAGS = -DSTRICT_R_HEADERS
PKG_CPPFLAGS = -DSTRICT_R_HEADERS -DRCPP_NO_MODULES
PKG_LIBS = -lWs2_32

#### Debugging flags ####
Expand Down
4 changes: 1 addition & 3 deletions src/later_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Loading