0

I am facing some issue on boost interruption . In MAC environment , I am not getting the boost_interrupted exception , even after setting the interrupt , and using the interruption point .

//Class Dummy
class A 
{ 
    public:
    // thread function 
    void thread_func(); 
    // other code 
    boost::shared_ptr<boost::thread>  mThread; 
} 
//Some function called from the main thread
void A::Some_Function() 
{ 
    // creating the thread
    mThread.reset(new boost::thread(boost::bind(&A::thread_func, this))); 
    // some other code 
} 

void A::thread_func() 
{ 
    try 
    { 
        While( something ) 
        { 
            //Setting the interruption point
            // error : interruption exception never caught 
            //interruption_enable : coming to false
            //interruption_request: true ( after setting the interrupt )
            boost::this_thread::interruption_point(); 
            // some code 
        } 
    } 
    // error : interruption exception never caught
    catch(boost_interrupted* excep) 
    { 
          // some handling 
    } 
} 

A::~A() 
{ 
    if( mThread.get() ) 
    { 
        mThread->interrupt(); 
        // even after setting the interrupt, the interrupted exception is not caught 
        mThread->join(); 
    } 
    mThread.reset(); 
}

Even after setting the interrupt in the destructor of the object, at the interruption point in thread_func() , exception is not thrown . What is shocking is that the thread is created with interruption_enable set to "false" .

After calling the interrupt , at the interruption point( inside the thread function ) , interruption_enable is false , and interruption_requested in true . Since interruption_enable is false it is not throwing the exception . I have not used any disable_interruption , then why it is being created with interruption_enable set to false ? Can some one please help me in figuring out the unusual behavior ? And also for me the problem is in MAC environment only .

0 Answers0