_Executed(false) ,
_graphName("") ,
_nodeName(""),
- _studyId(-1)
+ _studyId(-1),
+ _CanceledThread(false)
{
MESSAGE("Component constructor with instanceName "<< _instanceName);
//SCRUTE(pd_refCount);
_Executed(false) ,
_graphName("") ,
_nodeName(""),
- _studyId(-1)
+ _studyId(-1),
+ _CanceledThread(false)
{
_orb = CORBA::ORB::_duplicate(orb);
_poa = PortableServer::POA::_duplicate(poa);
#ifndef WNT
if ( _ThreadId > 0 && pthread_self() != _ThreadId )
{
- RetVal = Killer( _ThreadId , 0 ) ;
+ RetVal = Killer( _ThreadId , SIGUSR2 ) ;
_ThreadId = (pthread_t ) -1 ;
}
_ThreadCpuUsed = 0 ;
_Executed = true ;
_serviceName = serviceName ;
+ theEngines_Component = this ;
if ( pthread_setcanceltype( PTHREAD_CANCEL_ASYNCHRONOUS , NULL ) )
{
perror("pthread_setcanceltype ") ;
void Engines_Component_i::endService(const char *serviceName)
{
- _ThreadCpuUsed = CpuUsed_impl() ;
+ if ( !_CanceledThread )
+ _ThreadCpuUsed = CpuUsed_impl() ;
MESSAGE(pthread_self() << " Send EndService notification for " << serviceName
<< endl << " Component instance : " << _instanceName << " StartUsed "
<< _StartUsed << " _ThreadCpuUsed "<< _ThreadCpuUsed << endl <<endl);
void SetCpuUsed()
{
- theEngines_Component->SetCurCpu() ;
+ if ( theEngines_Component )
+ theEngines_Component->SetCurCpu() ;
}
//=============================================================================
return cpu ;
}
+void CallCancelThread()
+{
+ if ( theEngines_Component )
+ theEngines_Component->CancelThread() ;
+}
+
+//=============================================================================
+/*!
+ * C++ method:
+ */
+//=============================================================================
+
+void Engines_Component_i::CancelThread()
+{
+ _CanceledThread = true;
+}
+
//=============================================================================
/*!
* C++ method: Send message to event channel
perror("SALOME_Container main ") ;
exit(0) ;
}
+ if ( sigaction( SIGUSR2 , &SigIntAct, NULL ) )
+ {
+ perror("SALOME_Container main ") ;
+ exit(0) ;
+ }
//PAL9042 JR : during the execution of a Signal Handler (and of methods called through Signal Handlers)
// use of streams (and so on) should never be used because :
}
void SetCpuUsed() ;
+void CallCancelThread() ;
#ifndef WNT
void SigIntHandler(int what ,
{
SetCpuUsed() ;
}
+ else if ( siginfo->si_signo == SIGUSR2 )
+ {
+ CallCancelThread() ;
+ }
else
{
_Sleeping = true ;