Skip to content

checking for interupts #69

Description

@romainfrancois

Client packages need a clean way to check for interupts, i.e. the documented way (as of Writing R extensions) would potentially violate C++ destructors, meaning leaks, and potentially objects that are forever protected from the GC ...

In a R-devel thread, Simon posted this code:

static void chkIntFn(void *dummy) {
  R_CheckUserInterrupt();
}

// this will call the above in a top-level context so it won't longjmp-out of your context
bool checkInterrupt() {
  return (R_ToplevelExec(chkIntFn, NULL) == FALSE);
}

// your code somewhere ...
if (checkInterrupt()) { // user interrupted ... }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions