r-lib / later

Schedule an R function or formula to run after a specified period of time.
https://r-lib.github.io/later
Other
137 stars 27 forks source link

Check for later DLL version in header #103

Closed wch closed 5 years ago

wch commented 5 years ago

In the current development version of later, we introduced a new CCallable, execLaterNative2, which is called from inst/include/later.h. This header is compiled into other packages, like promises and httpuv. Here's the potential problem: if httpuv is compiled with the new version of this header (with execLaterNative2), and then run with the old version of later (with a DLL that does not have execLaterNative2), then it will throw this error when httpuv is loaded:

> loadNamespace('httpuv')
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  function 'execLaterNative2' not provided by package 'later'

This scenario could happen if:

This PR so far illustrates how we could check if the later DLL has the old API (without execLaterNative2), which we'll call the V1 API. The API provided by this version of later is V2.

Checking for the old API version is somewhat awkward, but going forward, we have two simpler options for retrieving the API version that the package was built with:

Then when later.h does its initialization stuff, we could check those values against the API version specified in the header.

wch commented 5 years ago

Closing in favor of #104.