- long cpu ;
- if ( getrusage( RUSAGE_SELF , &usage ) == -1 ) {
- perror("GraphBase::CpuUsed") ;
- return 0 ;
- }
-// return usage.ru_utime.__time_t tv_sec ;
- cout << "CpuUsed " << usage.ru_utime.tv_sec << " " << usage.ru_utime.tv_usec << " "
- << usage.ru_stime.tv_sec << " " << usage.ru_stime.tv_usec << endl ;
- cpu = usage.ru_utime.tv_sec - _StartUsed ;
+ if ( _ThreadId || _Executed )
+ {
+ if ( getrusage( RUSAGE_SELF , &usage ) == -1 )
+ {
+ perror("Engines_Component_i::CpuUsed") ;
+ return 0 ;
+ }
+ cpu = usage.ru_utime.tv_sec - _StartUsed ;
+ // cout << pthread_self() << " Engines_Component_i::CpuUsed " << " "
+ // << _serviceName << usage.ru_utime.tv_sec << " - " << _StartUsed
+ // << " = " << cpu << endl ;
+ }
+ else
+ {
+ // cout << pthread_self() << "Engines_Component_i::CpuUsed _ThreadId "
+ // << _ThreadId << " " << _serviceName<< " _StartUsed "
+ // << _StartUsed << endl ;
+ }
+ return cpu ;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+CORBA::Long Engines_Component_i::CpuUsed_impl()
+{
+ long cpu = 0 ;
+ if ( _ThreadId || _Executed )
+ {
+ if ( _ThreadId > 0 )
+ {
+ if ( pthread_self() != _ThreadId )
+ {
+ if ( _Sleeping )
+ {
+ }
+ else
+ {
+ // Get Cpu in the appropriate thread with that object !...
+ theEngines_Component = this ;
+ Killer( _ThreadId ,SIGUSR1 ) ;
+ }
+ cpu = _ThreadCpuUsed ;
+ }
+ else
+ {
+ _ThreadCpuUsed = CpuUsed() ;
+ cpu = _ThreadCpuUsed ;
+ // cout << pthread_self() << " Engines_Component_i::CpuUsed_impl "
+ // << _serviceName << " " << cpu << endl ;
+ }
+ }
+ else
+ {
+ cpu = _ThreadCpuUsed ;
+ // cout << pthread_self() << " Engines_Component_i::CpuUsed_impl "
+ // << _serviceName << " " << cpu<< endl ;
+ }
+ }
+ else
+ {
+ // cout << pthread_self()<<"Engines_Component_i::CpuUsed_impl _ThreadId "
+ // <<_ThreadId <<" "<<_serviceName<<" _StartUsed "<<_StartUsed<<endl;
+ }