int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { int result = 0; try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); if (parse_args (argc, argv) != 0) return 1; CORBA::Object_var tmp = orb->string_to_object(ior); Test_var server = Test::_narrow(tmp.in ()); if (CORBA::is_nil (server.in ())) { ACE_ERROR_RETURN ((LM_DEBUG, "Nil Test::Server reference <%s>\n", ior), 1); } server->test_method(); result =0; if (shutdown_server) { server->shutdown (); } orb->destroy (); } catch (const CORBA::Exception&) { result = 1; } return result; }
int Task::svc (void) { int result = 0; try { CORBA::Object_var object = this->orb_->string_to_object (ior); Test_var server = Test::_narrow (object.in ()); if (CORBA::is_nil (server.in ())) { ACE_ERROR_RETURN ((LM_ERROR, "ERROR: Object reference <%s> is nil\n", ior), -1); } // Check that the object is configured with CLIENT_PROPAGATED // PriorityModelPolicy. CORBA::Policy_var policy = server->_get_policy (RTCORBA::PRIORITY_MODEL_POLICY_TYPE); RTCORBA::PriorityModelPolicy_var priority_policy = RTCORBA::PriorityModelPolicy::_narrow (policy.in ()); if (CORBA::is_nil (priority_policy.in ())) ACE_ERROR_RETURN ((LM_ERROR, "ERROR: Priority Model Policy not exposed!\n"), -1); RTCORBA::PriorityModel priority_model = priority_policy->priority_model (); if (priority_model != RTCORBA::CLIENT_PROPAGATED) ACE_ERROR_RETURN ((LM_ERROR, "ERROR: priority_model != " "RTCORBA::CLIENT_PROPAGATED!\n"), -1); // Make several invocations, changing the priority of this thread // for each. object = this->orb_->resolve_initial_references ("RTCurrent"); RTCORBA::Current_var current = RTCORBA::Current::_narrow (object.in ()); object = this->orb_->resolve_initial_references ("PriorityMappingManager"); RTCORBA::PriorityMappingManager_var mapping_manager = RTCORBA::PriorityMappingManager::_narrow (object.in ()); RTCORBA::PriorityMapping *pm = mapping_manager->mapping (); int sched_policy = this->orb_->orb_core ()->orb_params ()->ace_sched_policy (); int max_priority = ACE_Sched_Params::priority_max (sched_policy); int min_priority = ACE_Sched_Params::priority_min (sched_policy); CORBA::Short native_priority = (max_priority - min_priority) / 2; CORBA::Short desired_priority = 0; for (int i = 0; i < 3; ++i) { if (pm->to_CORBA (native_priority, desired_priority) == 0) { ACE_ERROR ((LM_ERROR, "ERROR: Cannot convert native priority %d to corba priority\n", native_priority)); result = -1; break; } current->the_priority (desired_priority); CORBA::Short priority = current->the_priority (); if (desired_priority != priority) { ACE_ERROR ((LM_ERROR, "ERROR: No exception setting the priority but mismatch between requested and returned value from Current. " "Set to %d but Current::the_priority returns %d\n", desired_priority, priority)); result = -1; } server->test_method (priority); native_priority++; } // Shut down Server ORB. server->shutdown (); } catch (const CORBA::DATA_CONVERSION& ex) { ex._tao_print_exception ( "Most likely, this is due to the in-ability " "to set the thread priority."); return -1; } catch (const CORBA::Exception & ae) { ae._tao_print_exception ( "Caught exception:"); return -1; } return result; }