00001 // 00002 // $Id: RT_Current.cpp 82839 2008-09-26 11:09:19Z smcqueen $ 00003 // 00004 00005 #include "tao/RTCORBA/RT_Current.h" 00006 00007 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0 00008 00009 #include "tao/RTCORBA/Priority_Mapping.h" 00010 00011 #include "tao/Stub.h" 00012 #include "tao/ORB_Core.h" 00013 #include "tao/Protocols_Hooks.h" 00014 #include "tao/SystemException.h" 00015 00016 #include "ace/Thread.h" 00017 00018 ACE_RCSID (RTCORBA, 00019 RT_Current, 00020 "$Id: RT_Current.cpp 82839 2008-09-26 11:09:19Z smcqueen $") 00021 00022 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00023 00024 TAO_RT_Current::TAO_RT_Current (TAO_ORB_Core *orb_core) 00025 : orb_core_ (orb_core) 00026 { 00027 } 00028 00029 TAO_RT_Current::~TAO_RT_Current (void) 00030 { 00031 } 00032 00033 RTCORBA::Priority 00034 TAO_RT_Current::the_priority (void) 00035 { 00036 TAO_Protocols_Hooks *tph = this->orb_core_->get_protocols_hooks (); 00037 00038 RTCORBA::Priority priority = 0; 00039 00040 int result = 00041 tph->get_thread_CORBA_priority (priority); 00042 00043 if (result == -1) 00044 { 00045 if (TAO_debug_level > 0) 00046 ACE_DEBUG ((LM_DEBUG, "ERROR: TAO_RT_Current::the_priority. " 00047 "RT CORBA Priority accessed in a thread where it has not been set.\n")); 00048 // Spec does not define a minor code 00049 throw CORBA::INITIALIZE (); 00050 } 00051 00052 return priority; 00053 } 00054 00055 void 00056 TAO_RT_Current::the_priority (RTCORBA::Priority the_priority) 00057 { 00058 00059 TAO_Protocols_Hooks *tph = this->orb_core_->get_protocols_hooks (); 00060 00061 if (tph->set_thread_CORBA_priority (the_priority) == -1) 00062 { 00063 // Note this check is required by "2.6 Real-time Current" which states: 00064 // "A BAD_PARAM system exception shall be thrown if an attempt is made to set the 00065 // priority to a value outside the range 0 to 32767." 00066 // Note that it is not enough to assume that the mapping's rejection will deal with 00067 // this as it also says: "If the to_native call returns FALSE ... then a Real-time ORB 00068 // shall raise a DATA_CONVERSION system exception" i.e different exception. 00069 00070 if (the_priority < 0) // short 00071 throw CORBA::BAD_PARAM ( 00072 CORBA::SystemException::_tao_minor_code ( 00073 0, 00074 EINVAL), 00075 CORBA::COMPLETED_NO); 00076 00077 throw CORBA::DATA_CONVERSION (CORBA::OMGVMCID | 2, CORBA::COMPLETED_NO); 00078 } 00079 } 00080 00081 TAO_END_VERSIONED_NAMESPACE_DECL 00082 00083 #endif /* TAO_HAS_CORBA_MESSAGING && TAO_HAS_CORBA_MESSAGING != 0 */