+ 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 ;
+}
+
+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 ;