#include "RegistryConnexion.hxx"
#include "OpUtil.hxx"
#include <stdio.h>
+#ifndef WNT
#include <dlfcn.h>
+#endif
#include <cstdlib>
#include "utilities.h"
+#ifndef WNT
#include <sys/time.h>
#include <sys/resource.h>
#include <unistd.h>
+#else
+#include <sys/timeb.h>
+int SIGUSR11 = 1000;
+#endif
+
using namespace std;
// << dec ) ;
bool RetVal = false ;
+#ifndef WNT
if ( _ThreadId > 0 && pthread_self() != _ThreadId )
{
RetVal = Killer( _ThreadId , 0 ) ;
_ThreadId = (pthread_t ) -1 ;
}
+
+#else
+ if ( _ThreadId > 0 && pthread_self().p != _ThreadId->p )
+ {
+ RetVal = Killer( *_ThreadId , 0 ) ;
+ _ThreadId = (pthread_t* ) 0 ;
+ }
+
+#endif
return RetVal ;
}
bool RetVal = false ;
+#ifndef WNT
if ( _ThreadId > 0 && pthread_self() != _ThreadId )
{
RetVal = Killer( _ThreadId , 0 ) ;
_ThreadId = (pthread_t ) -1 ;
}
+#else
+ if ( _ThreadId > 0 && pthread_self().p != _ThreadId->p )
+ {
+ RetVal = Killer( *_ThreadId , 0 ) ;
+ _ThreadId = (pthread_t* ) 0 ;
+ }
+#endif
return RetVal ;
}
<< dec << " _ThreadId " << _ThreadId );
bool RetVal = false ;
+#ifndef WNT
if ( _ThreadId > 0 && pthread_self() != _ThreadId )
+#else
+ if ( _ThreadId > 0 && pthread_self().p != _ThreadId->p )
+#endif
{
if ( _Sleeping )
{
}
else
{
+#ifndef WNT
RetVal = Killer( _ThreadId ,SIGINT ) ;
+#else
+ RetVal = Killer( *_ThreadId ,SIGINT ) ;
+#endif
+
}
}
return RetVal ;
<< " machineName " << GetHostname().c_str()<< " _id " << hex << _id
<< dec << " _ThreadId " << _ThreadId );
bool RetVal = false ;
+#ifndef WNT
if ( _ThreadId > 0 && pthread_self() != _ThreadId )
+#else
+ if ( _ThreadId > 0 && pthread_self().p != _ThreadId->p )
+#endif
{
if ( _Sleeping )
{
{
if ( _ThreadId > 0 )
{
+#ifndef WNT
if ( pthread_self() != _ThreadId )
+#else
+ if ( pthread_self().p != _ThreadId->p )
+#endif
{
if ( _Sleeping )
{
{
// Get Cpu in the appropriate thread with that object !...
theEngines_Component = this ;
+#ifndef WNT
Killer( _ThreadId ,SIGUSR1 ) ;
+#else
+ Killer( *_ThreadId ,SIGUSR11 ) ;
+#endif
}
cpu = _ThreadCpuUsed ;
}
{
MESSAGE(pthread_self() << "Send BeginService notification for " <<serviceName
<< endl << "Component instance : " << _instanceName << endl << endl);
+#ifndef WNT
_ThreadId = pthread_self() ;
+#else
+ _ThreadId = new pthread_t;
+ _ThreadId->p = pthread_self().p ;
+ _ThreadId->x = pthread_self().x ;
+#endif
_StartUsed = 0 ;
_StartUsed = CpuUsed_impl() ;
_ThreadCpuUsed = 0 ;
bool Engines_Component_i::Killer( pthread_t ThreadId , int signum )
{
+#ifndef WNT
if ( ThreadId )
+#else
+ if ( ThreadId.p )
+#endif
{
if ( signum == 0 )
{
long Engines_Component_i::CpuUsed()
{
long cpu = 0 ;
+#ifndef WNT
struct rusage usage ;
if ( _ThreadId || _Executed )
{
// << _ThreadId << " " << _serviceName<< " _StartUsed "
// << _StartUsed << endl ;
}
+#else
+ // NOT implementet yet
+#endif
+
+
return cpu ;
}
//#define private public
#include <SALOMEconfig.h>
+#ifndef WNT
#include CORBA_SERVER_HEADER(SALOME_Component)
+#else
+#include <SALOME_Component.hh>
+#endif
#include "SALOME_Container_i.hxx"
#include "SALOME_Component_i.hxx"
#include "SALOME_NamingService.hxx"
#include "OpUtil.hxx"
#include <string.h>
#include <stdio.h>
+#ifndef WNT
#include <dlfcn.h>
#include <unistd.h>
+#else
+#include "../../adm/win32/SALOME_WNT.hxx"
+#include <signal.h>
+#include <process.h>
+int SIGUSR1 = 1000;
+#endif
#include <Python.h>
#include "Container_init_python.hxx"
// Other Containers are started via start_impl of FactoryServer
extern "C" {void ActSigIntHandler() ; }
+#ifndef WNT
extern "C" {void SigIntHandler(int, siginfo_t *, void *) ; }
+#else
+ extern "C" {void SigIntHandler( int ) ; }
+#endif
+
const char *Engines_Container_i::_defaultContainerName="FactoryServer";
map<std::string, int> Engines_Container_i::_cntInstances_map;
}
void* handle;
+#ifndef WNT
handle = dlopen( impl_name.c_str() , RTLD_LAZY ) ;
+#else
+ handle = dlopen( impl_name.c_str() , 0 ) ;
+#endif
if ( handle )
{
_library_map[impl_name] = handle;
INFOS("===============================================================");
//exit( 0 ) ;
ASSERT(0);
+ return false;
}
//=============================================================================
void ActSigIntHandler()
{
+#ifndef WNT
struct sigaction SigIntAct ;
SigIntAct.sa_sigaction = &SigIntHandler ;
SigIntAct.sa_flags = SA_SIGINFO ;
- // DEBUG 03.02.2005 : the first parameter of sigaction is not a mask of signals (SIGINT | SIGUSR1) :
- // it must be only one signal ===> one call for SIGINT and an other one for SIGUSR1
+#endif
+
+// DEBUG 03.02.2005 : the first parameter of sigaction is not a mask of signals (SIGINT | SIGUSR1) :
+// it must be only one signal ===> one call for SIGINT and an other one for SIGUSR1
+#ifndef WNT
if ( sigaction( SIGINT , &SigIntAct, NULL ) ) {
perror("SALOME_Container main ") ;
exit(0) ;
exit(0) ;
}
INFOS(pthread_self() << "SigIntHandler activated") ;
+#else
+ signal( SIGINT, SigIntHandler );
+ signal( SIGUSR1, SigIntHandler );
+#endif
+
}
void SetCpuUsed() ;
+#ifndef WNT
void SigIntHandler(int what , siginfo_t * siginfo ,
void * toto )
{
return ;
}
}
+#else // Case WNT
+void SigIntHandler( int what ) {
+ MESSAGE( pthread_self() << "SigIntHandler what " << what << endl );
+ if ( _Sleeping ) {
+ _Sleeping = false ;
+ MESSAGE("SigIntHandler END sleeping.") ;
+ return ;
+ }
+ else {
+ ActSigIntHandler() ;
+ if ( what == SIGUSR1 ) {
+ SetCpuUsed() ;
+ }
+ else {
+ _Sleeping = true ;
+ MESSAGE("SigIntHandler BEGIN sleeping.") ;
+ int count = 0 ;
+ while( _Sleeping ) {
+ Sleep( 1000 ) ;
+ count += 1 ;
+ }
+ MESSAGE("SigIntHandler LEAVE sleeping after " << count << " s.") ;
+ }
+ return ;
+ }
+}
+#endif
//=============================================================================
/*!
#include <iostream>
#include <signal.h>
#include <stdlib.h>
+#ifndef WNT
#include <unistd.h>
+#endif
#include <sys/types.h>
#include <string>
#include <map>
class RegistryConnexion;
-class Engines_Component_i: public virtual POA_Engines::Component,
+#if defined CONTAINER_EXPORTS
+#if defined WIN32
+#define CONTAINER_EXPORT __declspec( dllexport )
+#else
+#define CONTAINER_EXPORT
+#endif
+#else
+#if defined WNT
+#define CONTAINER_EXPORT __declspec( dllimport )
+#else
+#define CONTAINER_EXPORT
+#endif
+#endif
+
+class CONTAINER_EXPORT Engines_Component_i: public virtual POA_Engines::Component,
public virtual PortableServer::RefCountServantBase
{
public:
std::map<std::string,CORBA::Any>_fieldsDict;
private:
+#ifndef WNT
pthread_t _ThreadId ;
+#else
+ pthread_t* _ThreadId ;
+#endif
long _StartUsed ;
long _ThreadCpuUsed ;
bool _Executed ;
#include "SALOME_NamingService.hxx"
#include "OpUtil.hxx"
#include <sys/types.h>
+#ifndef WNT
#include <unistd.h>
+#endif
#include <vector>
#define TIME_OUT_TO_LAUNCH_CONT 21
else {
int count=TIME_OUT_TO_LAUNCH_CONT;
while ( CORBA::is_nil(ret) && count ) {
+#ifndef WNT
sleep( 1 ) ;
+#else
+ Sleep(1000);
+#endif
count-- ;
if ( count != 10 )
MESSAGE( count << ". Waiting for FactoryServer on " << theMachine);
class SALOME_NamingService;
-class SALOME_ContainerManager: public POA_Engines::ContainerManager,
+#if defined CONTAINER_EXPORTS
+#if defined WIN32
+#define CONTAINER_EXPORT __declspec( dllexport )
+#else
+#define CONTAINER_EXPORT
+#endif
+#else
+#if defined WNT
+#define CONTAINER_EXPORT __declspec( dllimport )
+#else
+#define CONTAINER_EXPORT
+#endif
+#endif
+
+class CONTAINER_EXPORT SALOME_ContainerManager: public POA_Engines::ContainerManager,
public PortableServer::RefCountServantBase {
private:
SALOME_ResourcesManager _ResManager;
#include <iostream>
#include <signal.h>
#include <stdlib.h>
+#ifndef WNT
#include <unistd.h>
+#endif
#include <sys/types.h>
#include <omnithread.h>
#include <map>
class SALOME_NamingService;
-class Engines_Container_i: public virtual POA_Engines::Container,
+
+#if defined CONTAINER_EXPORTS
+#if defined WIN32
+#define CONTAINER_EXPORT __declspec( dllexport )
+#else
+#define CONTAINER_EXPORT
+#endif
+#else
+#if defined WNT
+#define CONTAINER_EXPORT __declspec( dllimport )
+#else
+#define CONTAINER_EXPORT
+#endif
+#endif
+
+class CONTAINER_EXPORT Engines_Container_i: public virtual POA_Engines::Container,
public virtual PortableServer::RefCountServantBase
{
public: