Rcpp Version 1.0.8
piWithInterrupts.cpp File Reference
#include <Rcpp.h>
#include <R_ext/Utils.h>
Include dependency graph for piWithInterrupts.cpp:

Go to the source code of this file.


class  interrupt_exception


static void check_interrupt_impl (void *)
bool check_interrupt ()
RcppExport SEXP PiLeibniz (SEXP n, SEXP frequency)

Function Documentation

◆ check_interrupt()

bool check_interrupt ( )

Call this method to check for user interrupts. This is based on the results of a discussion on the R-devel mailing list, suggested by Simon Urbanek.

This method must not be called by any other thread than the master thread. If called from within an OpenMP parallel for loop, make sure to check for omp_get_thread_num()==0 before calling this method!
True, if a user interrupt has been detected.

Definition at line 64 of file piWithInterrupts.cpp.

References check_interrupt_impl().

Referenced by PiLeibniz().

Here is the call graph for this function:

◆ check_interrupt_impl()

static void check_interrupt_impl ( void *  )

Do the actual check for an interrupt.

This method should never be called directly.
[in]dummyDummy argument.

Definition at line 50 of file piWithInterrupts.cpp.

Referenced by check_interrupt().

◆ PiLeibniz()

RcppExport SEXP PiLeibniz ( SEXP  n,
SEXP  frequency 

Compute pi using the Leibniz formula (a very inefficient approach).

[in]nNumber of summands
[in]frequencyCheck for interrupts after every frequency loop cycles.

Definition at line 75 of file piWithInterrupts.cpp.

References BEGIN_RCPP, check_interrupt(), END_RCPP, Rcpp::algorithm::min(), and Rcpp::wrap().

Here is the call graph for this function: