Skip to content

Commit

Permalink
Make later.h compatible with old versions of later DLL
Browse files Browse the repository at this point in the history
  • Loading branch information
wch committed Sep 11, 2019
1 parent a6394f2 commit 97462f4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: later
Type: Package
Title: Utilities for Scheduling Functions to Execute Later with Event Loops
Version: 0.8.0.9003
Version: 0.8.0.9004
Authors@R: c(
person("Joe", "Cheng", role = c("aut", "cre"), email = "joe@rstudio.com"),
person(family = "RStudio", role = "cph"),
Expand Down
32 changes: 31 additions & 1 deletion inst/include/later.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,37 @@ inline void later(void (*func)(void*), void* data, double secs, int loop) {
}

inline void later(void (*func)(void*), void* data, double secs) {
later(func, data, secs, GLOBAL_LOOP);
typedef void (*elnfun)(void (*func)(void*), void*, double);
static elnfun eln = NULL;
if (!eln) {
// Initialize if necessary
if (func) {
// We're not initialized but someone's trying to actually schedule
// some code to be executed!
REprintf(
"Warning: later::execLaterNative called in uninitialized state. "
"If you're using <later.h>, please switch to <later_api.h>.\n"
);
}
eln = (elnfun)R_GetCCallable("later", "execLaterNative");
}

// We didn't want to execute anything, just initialize
if (!func) {
return;
}

eln(func, data, secs);


// Note 2019-09-11: The above code in this function is here just in case a
// package built with this version of later.h is run with an older version
// of the later DLL which does not have the execLaterNative2 function. In
// the next release of later, after we are confident that users have
// installed the newer later DLL which has execLaterNative2, it should be
// safe to replace the code in this function with just this:
//
// later(func, data, secs, GLOBAL_LOOP);
}


Expand Down

0 comments on commit 97462f4

Please sign in to comment.