{
void shutdown();
};
+
+ interface RequestSwitcher
+ {
+ void holdRequests();
+ void activeRequests();
+ };
interface DataScopeServerBase
{
boolean shutdownIfNotHostedByDSM(out DataScopeKiller killer) raises (SALOME::SALOME_Exception);
ByteVec fetchSerializedContent(in string varName) raises (SALOME::SALOME_Exception);
SeqOfByteVec getAllKeysOfVarWithTypeDict(in string varName) raises (SALOME::SALOME_Exception);
+ RequestSwitcher getRequestSwitcher();
};
interface DataScopeServer : DataScopeServerBase
const T& operator*() const { return *_ptr; }
operator T *() { return _ptr; }
operator const T *() const { return _ptr; }
+ bool isNull() const { return _ptr==NULL; }
private:
void destroyPtr()
{
_orb->shutdown(0);
}
+RequestSwitcher::RequestSwitcher(CORBA::ORB_ptr orb)
+{
+ CORBA::Object_var obj(orb->resolve_initial_references("RootPOA"));
+ PortableServer::POA_var poa(PortableServer::POA::_narrow(obj));
+ _poa_manager_under_control=poa->the_POAManager();
+ //
+ CORBA::PolicyList policies;
+ policies.length(1);
+ PortableServer::ThreadPolicy_var threadPol(poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL));
+ policies[0]=PortableServer::ThreadPolicy::_duplicate(threadPol);
+ // all is in PortableServer::POAManager::_nil. By specifying _nil cf Advanced CORBA Programming with C++ p 506
+ // a new POA manager is created. This POA manager is independant from POA manager of the son ones.
+ _poa_for_request_control=poa->create_POA("4RqstSwitcher",PortableServer::POAManager::_nil(),policies);
+ threadPol->destroy();
+ PortableServer::POAManager_var mgr(_poa_for_request_control->the_POAManager());
+ mgr->activate();
+}
+
+void RequestSwitcher::holdRequests()
+{
+ _poa_manager_under_control->hold_requests(true);
+}
+
+void RequestSwitcher::activeRequests()
+{
+ _poa_manager_under_control->activate();
+}
+
DataScopeServerBase::DataScopeServerBase(CORBA::ORB_ptr orb, SALOME::DataScopeKiller_var killer, const std::string& scopeName):_globals(0),_locals(0),_pickler(0),_orb(CORBA::ORB::_duplicate(orb)),_name(scopeName),_killer(killer)
{
}
return ret;
}
+SALOME::RequestSwitcher_ptr DataScopeServerBase::getRequestSwitcher()
+{
+ if(_rs.isNull())
+ {
+ _rs=new RequestSwitcher(_orb);
+ }
+ CORBA::Object_var obj(_rs->activate());
+ return SALOME::RequestSwitcher::_narrow(obj);
+}
+
void DataScopeServerBase::initializePython(int argc, char *argv[])
{
Py_Initialize();
CORBA::ORB_var _orb;
};
+ class SALOMESDS_EXPORT RequestSwitcher : public POA_SALOME::RequestSwitcher, public POAHolder
+ {
+ public:
+ RequestSwitcher(CORBA::ORB_ptr orb);
+ void holdRequests();
+ void activeRequests();
+ PortableServer::POA_var getPOA() const { return _poa_for_request_control; }
+ private:
+ PortableServer::POA_var _poa_for_request_control;
+ PortableServer::POAManager_var _poa_manager_under_control;
+ };
+
class KeyWaiter;
class PickelizedPyObjServer;
public:
DataScopeServerBase(CORBA::ORB_ptr orb, SALOME::DataScopeKiller_var killer, const std::string& scopeName);
DataScopeServerBase(const DataScopeServerBase& other);
+ public: // remote access methods
void ping();
char *getScopeName();
SALOME::StringVec *listVars();
CORBA::Boolean shutdownIfNotHostedByDSM(SALOME::DataScopeKiller_out killer);
SALOME::ByteVec *fetchSerializedContent(const char *varName);
SALOME::SeqOfByteVec *getAllKeysOfVarWithTypeDict(const char *varName);
- ~DataScopeServerBase();
+ SALOME::RequestSwitcher_ptr getRequestSwitcher();
public:
+ ~DataScopeServerBase();
BasicDataServer *retrieveVarInternal2(const std::string& varName);
void initializePython(int argc, char *argv[]);
void registerToSalomePiDict() const;
std::string _name;
std::list< std::pair< SALOME::BasicDataServer_var, BasicDataServer * > > _vars;
SALOME::DataScopeKiller_var _killer;
+ AutoServantPtr<RequestSwitcher> _rs;
static std::size_t COUNTER;
};