<commit_before>/************************************************************************************
**  
* @copyright (c) 2013-2100, ChengDu Duyer Technology Co., LTD. All Right Reserved.
*
*************************************************************************************/
/**
* @file		g_process_tracker.h
* @version     
* @brief      
* @author	duye
* @date		2014-10-11
* @note 
*
*  1. 2014-10-11 duye Created this file
* 
*/
#pragma once

#include <list>
#include <g_system.h>

namespace gcom {

/**
 * @biref process tracker
 */
class ProcessTracker : public gsys::ProcessSysCallbackObserver, public Singleton<ProcessTracker>
{
public:
    typedef SecrityObj<std::list<ProcessTrackerObserver*>> ObserverList;
    
public:    
    ProcessTracker();
    ~ProcessTracker();
    
    /**
     * @brife addition process  
     * @param [in] observer : process observer
     */
    void addProcess(gsys::Process* process);

    /**
     * @brief remove process 
     * @param [in] observer : process observer
     */
    void removeProcess(gsys::Process* process);
    
    /**
     * @brief wait process exit
     * @param [in] timeout : wait time, default is 2 seconds
     */
    void wait(const guint32 timeout = 2);
    
    /**
     * @brief wakeup all waiter thread
     */
    void wakeup();
    
private:
    // inherit from base class gsys::ProcessSysCallbackObserver 
    // system signal handler
    void signalHandler(const GInt32 sig);
    
private:    
    gsys::ProcessSysCallback    m_processSysCallback;
    ObserverList                m_observerList;
    Condition                   m_exitCondition;
};


}
<commit_msg>Update g_process_tracker.h<commit_after>/************************************************************************************
**  
* @copyright (c) 2013-2100, ChengDu Duyer Technology Co., LTD. All Right Reserved.
*
*************************************************************************************/
/**
* @file		g_process_tracker.h
* @version     
* @brief      
* @author	duye
* @date		2014-10-11
* @note 
*
*  1. 2014-10-11 duye Created this file
* 
*/
#pragma once

#include <list>
#include <g_system.h>

namespace gcom {

/**
 * @brief process monitor interface
 */
class ProcessObserver
{
public:
    virtual ~ProcessObserver() {}
    virtual void onSegFault(const GInt32 sig) = 0;
    virtual void onCtrlC(const GInt32 sig) = 0;
    virtual void onOther(const GInt32 sig) = 0;
};

/**
 * @biref process tracker
 */
class ProcessTracker : public gsys::ProcessSysCallbackObserver, public Singleton<ProcessTracker>
{
public:
    typedef SecrityObj<std::list<ProcessObserver*>> ObserverList;
    
public:    
    ProcessTracker();
    ~ProcessTracker();
    
    /**
     * @brife addition process  
     * @param [in] observer : process observer
     */
    void addObserver(ProcessObserver* observer);

    /**
     * @brief remove process 
     * @param [in] observer : process observer
     */
    void removeObserver(ProcessObserver* observer);
    
    /**
     * @brief wait process exit
     * @param [in] timeout : wait time, default is 2 seconds
     */
    void wait(const guint32 timeout = 2);
    
    /**
     * @brief wakeup all waiter thread
     */
    void wakeup();
    
private:
    // inherit from base class gsys::ProcessSysCallbackObserver 
    // system signal handler
    void signalHandler(const GInt32 sig);
    
private:    
    gsys::ProcessSysCallback    m_processSysCallback;
    ObserverList                m_observerList;
    Condition                   m_exitCondition;
};

}

{'fraction_non_alphanumeric': 0.1953344575604272, 'fraction_numerical': 0.019955030916245082, 'mean_word_length': 2.976536312849162, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2394470', 'n_tokens_mistral': 1079, 'n_tokens_neox': 993, 'n_words': 264}