Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / RTCORBA / check_supported_priorities.cpp
blob11ff3473e08d110c9dc70733c99781ab05944c6f
1 #include "ace/Sched_Params.h"
2 #include "tao/ORB_Core.h"
3 #include "tao/ORB.h"
4 #include "tao/RTCORBA/Priority_Mapping_Manager.h"
5 #include "tao/Protocols_Hooks.h"
7 const char *
8 sched_policy_name (int sched_policy)
10 const char *name = 0;
12 switch (sched_policy)
14 case ACE_SCHED_OTHER:
15 name = "SCHED_OTHER";
16 break;
17 case ACE_SCHED_RR:
18 name = "SCHED_RR";
19 break;
20 case ACE_SCHED_FIFO:
21 name = "SCHED_FIFO";
22 break;
25 return name;
28 bool
29 check_supported_priorities (CORBA::ORB_ptr orb)
31 int sched_policy =
32 orb->orb_core ()->orb_params ()->ace_sched_policy ();
34 // Check that we have sufficient priority range to run this test,
35 // i.e., more than 1 priority level.
36 int max_priority =
37 ACE_Sched_Params::priority_max (sched_policy);
38 int min_priority =
39 ACE_Sched_Params::priority_min (sched_policy);
41 if (max_priority == min_priority)
43 ACE_DEBUG ((LM_DEBUG,
44 "Not enough priority levels with the %C scheduling policy\n"
45 "on this platform to run the test, terminating program....\n"
46 "Check svc.conf options\n",
47 sched_policy_name (sched_policy)));
49 return false;
52 return true;
55 CORBA::Short
56 get_implicit_thread_CORBA_priority (CORBA::ORB_ptr orb)
58 CORBA::Object_var obj =
59 orb->resolve_initial_references (TAO_OBJID_PRIORITYMAPPINGMANAGER);
61 TAO_Priority_Mapping_Manager_var mapping_manager =
62 TAO_Priority_Mapping_Manager::_narrow (obj.in ());
64 if (CORBA::is_nil (mapping_manager.in ()))
65 throw CORBA::INTERNAL ();
67 RTCORBA::PriorityMapping *pm =
68 mapping_manager.in ()->mapping ();
70 TAO_Protocols_Hooks *tph =
71 orb->orb_core ()->get_protocols_hooks ();
73 CORBA::Short corba_priority;
74 CORBA::Short native_priority;
76 if (tph->get_thread_native_priority (native_priority) == 0 &&
77 pm->to_CORBA (native_priority, corba_priority))
79 return corba_priority;
82 ACE_DEBUG ((LM_DEBUG, "get_implicit_thread_CORBA_priority - failed to access priority\n"));
83 throw CORBA::DATA_CONVERSION (CORBA::OMGVMCID | 2, CORBA::COMPLETED_NO);