ExitManager Class Reference

manages the ordered exiting of the program More...

Collaboration diagram for ExitManager:

Collaboration graph
[legend]

List of all members.

Public Types

typedef void(* cleanup_function )(void)

Static Public Member Functions

static void StopFactorization ()
 cancel all registered thread, clean-up resources and exit the program
static void register_cancel (const pthread_t tid=pthread_self())
 register a thread for possible cancellation
static void unregister_cancel (const pthread_t tid=pthread_self())
 unregister a thread for cancellation
static void cancel_registered_threads ()
 cancel all registered threads
static void register_exithandler (cleanup_function a_cleanup_function)
 register an exithandler
static void StopFactorization ()

Static Private Attributes

static stack< cleanup_functioncleanup_functions
static CMutex Mutex
static CMutex AliveMutex


Detailed Description

manages the ordered exiting of the program

This class manages the ordered exiting of the program after the factorization has been ended or aborted by program flow. For one reason, there are some data structures (files, etc.) that should be closed and even deleted. The other reason is, that in server mode there may be some threads running unaware of the fact, that factorization has stopped. So the general idea of this manager class is to notify or cancel these threads, too...

Definition at line 26 of file easy_factor.cc.


Member Typedef Documentation

typedef void(* ExitManager::cleanup_function)(void)


Member Function Documentation

void ExitManager::StopFactorization (  )  [static]

cancel all registered thread, clean-up resources and exit the program

Definition at line 118 of file ExitManager.cc.

References AliveMutex, std::basic_string< _CharT, _Traits, _Alloc >::c_str(), cancel_registered_threads(), catch_sigint(), cleanup_functions, cout, endl(), exit(), flush(), FoundFactors, CMutex::lock(), MARK, TFoundFactors::PrettyPrint(), PrintSummary, statistical_data::StatusReport(), XML_StatusFile, and statistical_data::XML_StatusReport().

Referenced by easy_factor(), StaticRelations::insert(), Cprocess_clients::process_data_stream(), Cprocess_clients::process_data_stream_ecm(), and process_ecm().

Here is the call graph for this function:

void ExitManager::register_cancel ( const pthread_t  tid = pthread_self()  )  [static]

register a thread for possible cancellation

Definition at line 58 of file ExitManager.cc.

References CMutex::lock(), Mutex, and CMutex::unlock().

Referenced by Cprocess_clients::THREAD_process_data_stream(), and CXML_StatusServer::THREAD_XML_StatusServer().

Here is the call graph for this function:

void ExitManager::unregister_cancel ( const pthread_t  tid = pthread_self()  )  [static]

unregister a thread for cancellation

Definition at line 66 of file ExitManager.cc.

References CMutex::lock(), Mutex, and CMutex::unlock().

Referenced by Cprocess_clients::THREAD_process_data_stream().

Here is the call graph for this function:

void ExitManager::cancel_registered_threads (  )  [static]

cancel all registered threads

Definition at line 74 of file ExitManager.cc.

References cerr, cout, endl(), CMutex::lock(), Mutex, and CMutex::unlock().

Referenced by StopFactorization().

Here is the call graph for this function:

void ExitManager::register_exithandler ( cleanup_function  a_cleanup_function  )  [static]

register an exithandler

Definition at line 97 of file ExitManager.cc.

References cleanup_functions.

Referenced by main().

static void ExitManager::StopFactorization (  )  [static]


Member Data Documentation

stack< ExitManager::cleanup_function > ExitManager::cleanup_functions [static, private]

Definition at line 31 of file ExitManager.cc.

Referenced by register_exithandler(), and StopFactorization().

CMutex ExitManager::Mutex [static, private]

Definition at line 33 of file ExitManager.cc.

Referenced by cancel_registered_threads(), register_cancel(), and unregister_cancel().

CMutex ExitManager::AliveMutex [static, private]

Definition at line 33 of file ExitManager.cc.

Referenced by StopFactorization().


The documentation for this class was generated from the following files:
Generated on Wed Nov 7 23:31:51 2007 for Qsieve by  doxygen 1.5.4