RcppThread::RMonitor class

Singleton class for tracking threads and safe communication.

Public static functions

static auto instance() -> RMonitor&

Constructors, destructors, conversion operators

RMonitor(RMonitor const&) deleted
copy constructor (forbidden)
RMonitor(RMonitor&&) deleted
move constructor (forbidden)

Public functions

auto operator=(RMonitor const&) -> RMonitor& deleted
copy assignment (forbidden)
auto operator=(RMonitor&&) -> RMonitor& deleted
move assignment (forbidden)

Protected functions

auto calledFromMainThread() -> bool
returns true only when called from main thread.
void safelycheckUserInterrupt()
checks for user interruptions, but only if called from main thread.
auto safelyIsInterrupted() -> bool
template<class T>
void safelyPrint(const T& object)
template<class T>
void safelyPrintErr(const T& object)

Friends

void checkUserInterrupt(bool condition)
auto isInterrupted(bool condition) -> bool

Function documentation

static RMonitor& RcppThread::RMonitor::instance()

constructs the instance when called for the first time, returns ref to instance.

bool RcppThread::RMonitor::safelyIsInterrupted() protected

checks for user interruptions, but only if called from main thread (otherwise last known state is returned).

template<class T>
void RcppThread::RMonitor::safelyPrint(const T& object) protected

Parameters
object a string or coercible object to print.

prints object to R console íf called from main thread; otherwise adds a printable version of object to a buffer for deferred printing.

template<class T>
void RcppThread::RMonitor::safelyPrintErr(const T& object) protected

Parameters
object a string or coercible object to print.

prints object to R error stream íf called from main thread; otherwise adds a printable version of object to a buffer for deferred printing.

void checkUserInterrupt(bool condition)

Parameters
condition optional; a condition for the check to be executed.

checks for user interruptions, but only if called from main thread. Declared as a friend in RMonitor.

bool isInterrupted(bool condition)

Parameters
condition optional; a condition for the check to be executed.

checks for user interruptions, but only if called from main thread (otherwise returns false). Declared as a friend in RMonitor.