Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tao / RTCORBA / RT_Current.cpp
blobb38ba801416d928efad6337fd288dc542e0de735
1 #include "tao/RTCORBA/RT_Current.h"
3 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
5 #include "tao/RTCORBA/Priority_Mapping.h"
7 #include "tao/Stub.h"
8 #include "tao/ORB_Core.h"
9 #include "tao/Protocols_Hooks.h"
10 #include "tao/SystemException.h"
12 #include "ace/Thread.h"
14 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
16 TAO_RT_Current::TAO_RT_Current (TAO_ORB_Core *orb_core)
17 : orb_core_ (orb_core)
21 TAO_RT_Current::~TAO_RT_Current ()
25 RTCORBA::Priority
26 TAO_RT_Current::the_priority ()
28 TAO_Protocols_Hooks *tph = this->orb_core_->get_protocols_hooks ();
30 RTCORBA::Priority priority = 0;
32 int const result =
33 tph->get_thread_CORBA_priority (priority);
35 if (result == -1)
37 if (TAO_debug_level > 0)
38 TAOLIB_DEBUG ((LM_DEBUG, "ERROR: TAO_RT_Current::the_priority. "
39 "RT CORBA Priority accessed in a thread where it has not been set.\n"));
40 // Spec does not define a minor code
41 throw CORBA::INITIALIZE ();
44 return priority;
47 void
48 TAO_RT_Current::the_priority (RTCORBA::Priority the_priority)
50 TAO_Protocols_Hooks *tph = this->orb_core_->get_protocols_hooks ();
52 if (tph->set_thread_CORBA_priority (the_priority) == -1)
54 // Note this check is required by "2.6 Real-time Current" which states:
55 // "A BAD_PARAM system exception shall be thrown if an attempt is made to set the
56 // priority to a value outside the range 0 to 32767."
57 // Note that it is not enough to assume that the mapping's rejection will deal with
58 // this as it also says: "If the to_native call returns FALSE ... then a Real-time ORB
59 // shall raise a DATA_CONVERSION system exception" i.e different exception.
61 if (the_priority < 0) // short
62 throw CORBA::BAD_PARAM (
63 CORBA::SystemException::_tao_minor_code (
65 EINVAL),
66 CORBA::COMPLETED_NO);
68 throw CORBA::DATA_CONVERSION (CORBA::OMGVMCID | 2, CORBA::COMPLETED_NO);
72 TAO_END_VERSIONED_NAMESPACE_DECL
74 #endif /* TAO_HAS_CORBA_MESSAGING && TAO_HAS_CORBA_MESSAGING != 0 */