本文整理汇总了C++中Test_var::_get_policy方法的典型用法代码示例。如果您正苦于以下问题:C++ Test_var::_get_policy方法的具体用法?C++ Test_var::_get_policy怎么用?C++ Test_var::_get_policy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Test_var
的用法示例。
在下文中一共展示了Test_var::_get_policy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: thread_barrier
int
Task::svc (void)
{
try
{
// Priority Mapping Manager.
CORBA::Object_var object =
this->orb_->resolve_initial_references ("PriorityMappingManager");
RTCORBA::PriorityMappingManager_var mapping_manager =
RTCORBA::PriorityMappingManager::_narrow (object.in ());
if (check_for_nil (mapping_manager.in (), "Mapping Manager") == -1)
return -1;
RTCORBA::PriorityMapping *pm =
mapping_manager->mapping ();
// RTCurrent.
object =
this->orb_->resolve_initial_references ("RTCurrent");
RTCORBA::Current_var current =
RTCORBA::Current::_narrow (object.in ());
if (check_for_nil (current.in (), "RTCurrent") == -1)
return -1;
// Obtain Test object reference.
object =
this->orb_->string_to_object (ior);
Test_var server = Test::_narrow (object.in ());
if (check_for_nil (server.in (), "Test object") == -1)
return -1;
// Check that test 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 (check_for_nil (priority_policy.in (), "PriorityModelPolicy") == -1)
return -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);
// Spawn two worker threads.
ACE_Barrier thread_barrier (2);
int flags =
THR_NEW_LWP |
THR_JOINABLE |
this->orb_->orb_core ()->orb_params ()->thread_creation_flags ();
// Worker 1.
Worker_Thread worker1 (this->orb_.in (),
server.in (),
protocol1,
&thread_barrier);
CORBA::Short native_priority1 = 0;
if (pm->to_native (priority1, native_priority1) == 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot convert corba priority %d to native priority\n",
priority1),
-1);
if (worker1.activate (flags,
1, 0,
native_priority1) != 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot activate first client worker threads\n"),
-1);
// Worker 2.
Worker_Thread worker2 (this->orb_.in (),
server.in (),
protocol2,
&thread_barrier);
CORBA::Short native_priority2 = 0;
if (pm->to_native (priority2, native_priority2) == 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot convert corba priority %d to native priority\n",
priority2),
-1);
if (worker2.activate (flags,
1, 0,
native_priority2) != 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot activate second client worker threads\n"),
-1);
// Wait for worker threads to finish.
ACE_Thread_Manager::instance ()->wait ();
//.........这里部分代码省略.........
示例2: catch
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++;
//.........这里部分代码省略.........