Skip to content

Commit

Permalink
CheckInterrupt
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengxwen committed Dec 25, 2024
1 parent 7a36fcb commit 9496df7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/ConvVCF2GDS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,15 @@ extern "C"
{
using namespace SeqArray;

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

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


// ===========================================================
// Get the number of lines in a VCF file
// ===========================================================
Expand Down Expand Up @@ -1084,6 +1093,7 @@ COREARRAY_DLL_EXPORT SEXP SEQ_VCF_NumLines(SEXP File, SEXP SkipHead,
{
m0 = 0;
Rprintf(".");
if (CheckInterrupt()) Rf_error("User interrupt.");
if ((++m1) % 50 == 0)
Rprintf(" %ldK [%s]\n", (long int)n/1000, datetime_str());
}
Expand Down

0 comments on commit 9496df7

Please sign in to comment.