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

Save function pointers in model object #1232

Open
kylebaron opened this issue Sep 10, 2024 · 0 comments
Open

Save function pointers in model object #1232

kylebaron opened this issue Sep 10, 2024 · 0 comments

Comments

@kylebaron
Copy link
Collaborator

kylebaron commented Sep 10, 2024

I think rather than making it work like this by default, instead let the user cache the pointers for when the model is getting run over and over.

  1. Helper functions to setpointers() and getpointers()
  2. Put C++ code in mrgsolve.cpp
  3. Put function in mrgsolve_init.cpp
  4. Optional refresh
  5. Modify loadso()
  6. Modify mread()
  7. Modify mread_cache()
// [[Rcpp::export]]
bool VALIDPOINTERS(Rcpp::List x) {
  if(x.size()==0) return false;
  for(size_t i = 0; i < x.size(); ++i) {
    if(R_ExternalPtrAddr(x[i]) == NULL) {
      return false;  
    }
  }
  return true;
}
setpointers <- function(x) {
  x@shlib$pointers <- pointers(x, refresh = TRUE)
  x
}

getpointers <- function(x) {
  x@shlib$pointers  
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant