SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Static Protected Attributes
CSignal Class Reference

Detailed Description

Class Signal implements signal handling to e.g. allow ctrl+c to cancel a long running process.

This is done in two ways:

  1. A signal handler is attached to trap the SIGINT and SIGURG signal. Pressing ctrl+c or sending the SIGINT (kill ...) signal to the shogun process will make shogun print a message asking to immediately exit the running method and to fall back to the command line.
  2. When an URG signal is received or ctrl+c P is pressed shogun will prematurely stop a method and continue execution. For example when an SVM solver takes a long time without progressing much, one might still be interested in the result and should thus send SIGURG or interactively prematurely stop the method

Definition at line 47 of file Signal.h.

Inheritance diagram for CSignal:
Inheritance graph
[legend]

Public Member Functions

 CSignal ()
virtual ~CSignal ()
virtual const char * get_name () const
- Public Member Functions inherited from CSGObject
 CSGObject ()
 CSGObject (const CSGObject &orig)
virtual ~CSGObject ()
virtual bool is_generic (EPrimitiveType *generic) const
template<class T >
void set_generic ()
void unset_generic ()
virtual void print_serializable (const char *prefix="")
virtual bool save_serializable (CSerializableFile *file, const char *prefix="")
virtual bool load_serializable (CSerializableFile *file, const char *prefix="")
void set_global_io (SGIO *io)
SGIOget_global_io ()
void set_global_parallel (Parallel *parallel)
Parallelget_global_parallel ()
void set_global_version (Version *version)
Versionget_global_version ()
SGVector< char * > get_modelsel_names ()
char * get_modsel_param_descr (const char *param_name)
index_t get_modsel_param_index (const char *param_name)

Static Public Member Functions

static void handler (int signal)
static bool set_handler ()
static bool unset_handler ()
static void clear ()
static void clear_cancel ()
static void set_cancel (bool immediately=false)
static bool cancel_computations ()

Static Protected Attributes

static int signals [NUMTRAPPEDSIGS] = {SIGINT, SIGURG}
static struct sigaction oldsigaction [NUMTRAPPEDSIGS]
static bool active = false
static bool cancel_computation = false
static bool cancel_immediately = false

Additional Inherited Members

- Public Attributes inherited from CSGObject
SGIOio
Parallelparallel
Versionversion
Parameterm_parameters
Parameterm_model_selection_parameters
- Protected Member Functions inherited from CSGObject
virtual void load_serializable_pre () throw (ShogunException)
virtual void load_serializable_post () throw (ShogunException)
virtual void save_serializable_pre () throw (ShogunException)
virtual void save_serializable_post () throw (ShogunException)

Constructor & Destructor Documentation

CSignal ( )

default constructor

Definition at line 30 of file Signal.cpp.

~CSignal ( )
virtual

Definition at line 35 of file Signal.cpp.

Member Function Documentation

static bool cancel_computations ( )
static

cancel computations

Returns
if computations should be cancelled

Definition at line 85 of file Signal.h.

void clear ( )
static

clear signals

Definition at line 142 of file Signal.cpp.

void clear_cancel ( )
static

clear cancel flag signals

Definition at line 128 of file Signal.cpp.

virtual const char* get_name ( ) const
virtual
Returns
object name

Implements CSGObject.

Definition at line 98 of file Signal.h.

void handler ( int  signal)
static

handler

Parameters
signalsignal number

Definition at line 41 of file Signal.cpp.

void set_cancel ( bool  immediately = false)
static

set cancel flag signals

Definition at line 134 of file Signal.cpp.

bool set_handler ( )
static

set handler

Returns
if setting was successful

Definition at line 66 of file Signal.cpp.

bool unset_handler ( )
static

unset handler

Returns
if unsetting was successful

Definition at line 104 of file Signal.cpp.

Member Data Documentation

bool active = false
staticreadprotected

active signal

Definition at line 108 of file Signal.h.

bool cancel_computation = false
staticprotected

if computation should be cancelled

Definition at line 111 of file Signal.h.

bool cancel_immediately = false
staticprotected

if shogun should return ASAP

Definition at line 114 of file Signal.h.

struct sigaction oldsigaction[NUMTRAPPEDSIGS]
staticprotected

signal actions

Definition at line 105 of file Signal.h.

int signals = {SIGINT, SIGURG}
staticprotected

signals; handling external lib

Definition at line 102 of file Signal.h.


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

SHOGUN Machine Learning Toolbox - Documentation