diff --git a/DESCRIPTION b/DESCRIPTION index 2630bc2..813a0c7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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"), diff --git a/inst/include/later.h b/inst/include/later.h index 1f02d91..ff67efc 100644 --- a/inst/include/later.h +++ b/inst/include/later.h @@ -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 , please switch to .\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); }