int Task::svc (void) { try { CORBA::Object_var object = this->orb_->resolve_initial_references ("RTORB"); RTCORBA::RTORB_var rt_orb = RTCORBA::RTORB::_narrow (object.in ()); object = this->orb_->resolve_initial_references ("RootPOA"); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (object.in ()); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); CORBA::PolicyList policies; int result = get_priority_bands ("server", bands_file, rt_orb.in (), policies, debug); if (result != 0) return result; result = get_priority_lanes ("server", lanes_file, rt_orb.in (), stacksize, static_threads, dynamic_threads, allow_request_buffering, max_buffered_requests, max_request_buffer_size, allow_borrowing, policies, debug); if (result != 0) return result; CORBA::Policy_var priority_model_policy = rt_orb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED, 0); // Implicit_activation policy. CORBA::Policy_var implicit_activation_policy = root_poa->create_implicit_activation_policy (PortableServer::IMPLICIT_ACTIVATION); policies.length (policies.length () + 1); policies[policies.length () - 1] = priority_model_policy; policies.length (policies.length () + 1); policies[policies.length () - 1] = implicit_activation_policy; PortableServer::POA_var poa = root_poa->create_POA ("child", poa_manager.in (), policies); test_i *servant = 0; ACE_NEW_THROW_EX (servant, test_i (this->orb_.in (), poa.in ()), CORBA::NO_MEMORY ()); PortableServer::ServantBase_var safe_servant (servant); PortableServer::ObjectId_var id = poa->activate_object (servant); CORBA::Object_var object_act = poa->id_to_reference (id.in ()); test_var test = test::_narrow (object_act.in ()); write_iors_to_file (test.in (), this->orb_.in (), ior); poa_manager->activate (); this->orb_->run (); this->orb_->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught"); return -1; } return 0; }
int Task::svc (void) { try { CORBA::Object_var object = this->orb_->resolve_initial_references ("RootPOA"); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (object.in ()); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); object = this->orb_->resolve_initial_references ("RTORB"); RTCORBA::RTORB_var rt_orb = RTCORBA::RTORB::_narrow (object.in ()); object = this->orb_->resolve_initial_references ("RTCurrent"); RTCORBA::Current_var current = RTCORBA::Current::_narrow (object.in ()); default_thread_priority = current->the_priority (); int result = 0; CORBA::ULong stacksize = 0; CORBA::Boolean allow_request_buffering = 0; CORBA::ULong max_buffered_requests = 0; CORBA::ULong max_request_buffer_size = 0; CORBA::PolicyList policies; CORBA::Boolean allow_borrowing = 0; if (number_of_lanes != 0) { get_auto_priority_lanes_and_bands (number_of_lanes, rt_orb.in (), stacksize, static_threads, dynamic_threads, allow_request_buffering, max_buffered_requests, max_request_buffer_size, allow_borrowing, policies, 1); } else if (ACE_OS::strcmp (lanes_file, ACE_TEXT("empty-file")) != 0) { result = get_priority_lanes ("server", lanes_file, rt_orb.in (), stacksize, static_threads, dynamic_threads, allow_request_buffering, max_buffered_requests, max_request_buffer_size, allow_borrowing, policies, 1); if (result != 0) return result; result = get_priority_bands ("server", bands_file, rt_orb.in (), policies, 1); if (result != 0) return result; } else { if (pool_priority == ACE_INT16_MIN) pool_priority = default_thread_priority; RTCORBA::ThreadpoolId threadpool_id = rt_orb->create_threadpool (stacksize, static_threads, dynamic_threads, pool_priority, allow_request_buffering, max_buffered_requests, max_request_buffer_size); policies.length (policies.length () + 1); policies[policies.length () - 1] = rt_orb->create_threadpool_policy (threadpool_id); if (ACE_OS::strcmp (bands_file, ACE_TEXT("empty-file")) != 0) { result = get_priority_bands ("server", bands_file, rt_orb.in (), policies, 1); if (result != 0) return result; } } policies.length (policies.length () + 1); policies[policies.length () - 1] = root_poa->create_implicit_activation_policy (PortableServer::IMPLICIT_ACTIVATION); policies.length (policies.length () + 1); policies[policies.length () - 1] = rt_orb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED, default_thread_priority); PortableServer::POA_var poa = root_poa->create_POA ("RT POA", poa_manager.in (), policies); test_i *servant = new test_i (this->orb_.in (), poa.in ()); PortableServer::ServantBase_var safe_servant (servant); ACE_UNUSED_ARG (safe_servant); test_var test = servant->_this (); result = write_ior_to_file (ior_output_file, this->orb_.in (), test.in ()); if (result != 0) return result; poa_manager->activate (); this->orb_->run (); this->orb_->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught:"); return 1; } return 0; }