RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
RDKit::ControlCHandler Class Reference

#include <ControlCHandler.h>

Public Member Functions

 ControlCHandler ()
 
 ControlCHandler (const ControlCHandler &)=delete
 
 ControlCHandler (ControlCHandler &&)=delete
 
ControlCHandleroperator= (const ControlCHandler &)=delete
 
ControlCHandleroperator= (ControlCHandler &&)=delete
 
 ~ControlCHandler ()
 

Static Public Member Functions

static bool getGotSignal ()
 
static void signalHandler (int signalNumber)
 
static void reset ()
 

Detailed Description

This class catches a control-C/SIGINT and sets the flag d_gotSignal if one is received. It is intended to be used inside a long C++ calculation called from Python which intercepts the signal handler. The C++ code must check the value of d_gotSignal periodically and act accordingly. The destructor resets the signal handler and flag for next use, which is essential because it's a static variable. Example usage, inside a boost::python wrapper: ResultsObject results; { NOGIL gil; results = someFunction(); } if (results.getCancelled()) { throw_runtime_error("someFunction cancelled"); } It's important that the exception is thrown once the GIL has been released, otherwise a crash is inevitable at some future point.

Definition at line 38 of file ControlCHandler.h.

Constructor & Destructor Documentation

◆ ControlCHandler() [1/3]

RDKit::ControlCHandler::ControlCHandler ( )
inline

Definition at line 40 of file ControlCHandler.h.

References RDKit::rdvalue_is(), and signalHandler().

◆ ControlCHandler() [2/3]

RDKit::ControlCHandler::ControlCHandler ( const ControlCHandler )
delete

◆ ControlCHandler() [3/3]

RDKit::ControlCHandler::ControlCHandler ( ControlCHandler &&  )
delete

◆ ~ControlCHandler()

RDKit::ControlCHandler::~ControlCHandler ( )
inline

Definition at line 45 of file ControlCHandler.h.

References RDKit::rdvalue_is().

Member Function Documentation

◆ getGotSignal()

static bool RDKit::ControlCHandler::getGotSignal ( )
inlinestatic

Definition at line 49 of file ControlCHandler.h.

◆ operator=() [1/2]

ControlCHandler & RDKit::ControlCHandler::operator= ( const ControlCHandler )
delete

◆ operator=() [2/2]

ControlCHandler & RDKit::ControlCHandler::operator= ( ControlCHandler &&  )
delete

◆ reset()

static void RDKit::ControlCHandler::reset ( )
inlinestatic

Definition at line 56 of file ControlCHandler.h.

References RDKit::rdvalue_is(), and signalHandler().

◆ signalHandler()

static void RDKit::ControlCHandler::signalHandler ( int  signalNumber)
inlinestatic

Definition at line 50 of file ControlCHandler.h.

References RDKit::rdvalue_is().

Referenced by ControlCHandler(), and reset().


The documentation for this class was generated from the following file: