1 // Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony GEAY (EDF R&D)
21 #include "SALOMESDS_RequestSwitcher.hxx"
25 using namespace SALOMESDS;
27 RequestSwitcherBase::RequestSwitcherBase(CORBA::ORB_ptr orb)
30 CORBA::Object_var obj(orb->resolve_initial_references("RootPOA"));
31 PortableServer::POA_var poa(PortableServer::POA::_narrow(obj));
32 _poa_manager_under_control=poa->the_POAManager();
34 CORBA::PolicyList policies;
36 PortableServer::ThreadPolicy_var threadPol(poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL));
37 policies[0]=PortableServer::ThreadPolicy::_duplicate(threadPol);
38 // all is in PortableServer::POAManager::_nil. By specifying _nil cf Advanced CORBA Programming with C++ p 506
39 // a new POA manager is created. This POA manager is independent from POA manager of the son ones.
40 std::ostringstream poaName;
41 poaName << "4RqstSwitcher_" << iii++;
42 _poa_for_request_control=poa->create_POA(poaName.str().c_str(),PortableServer::POAManager::_nil(),policies);
44 PortableServer::POAManager_var mgr(_poa_for_request_control->the_POAManager());
46 //obj=orb->resolve_initial_references ("POACurrent");// agy : usage of POACurrent breaks the hold_requests. Why ?
47 //PortableServer::Current_var current(PortableServer::Current::_narrow(obj));
50 void RequestSwitcherBase::holdRequests()
52 _poa_manager_under_control->hold_requests(true);
55 void RequestSwitcherBase::activeRequests()
57 _poa_manager_under_control->activate();