RT_Protocols_Hooks.cpp

Go to the documentation of this file.
00001 #include "tao/RTCORBA/RT_Protocols_Hooks.h"
00002 
00003 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
00004 
00005 #include "tao/RTCORBA/RT_Policy_i.h"
00006 #include "tao/RTCORBA/Priority_Mapping_Manager.h"
00007 #include "tao/RTCORBA/RT_Stub.h"
00008 
00009 #include "tao/Stub.h"
00010 #include "tao/ORB_Core.h"
00011 #include "tao/MProfile.h"
00012 #include "tao/Service_Context.h"
00013 #include "tao/Acceptor_Registry.h"
00014 #include "tao/Thread_Lane_Resources.h"
00015 #include "tao/Protocol_Factory.h"
00016 #include "tao/Transport_Acceptor.h"
00017 #include "tao/Transport_Connector.h"
00018 #include "tao/Policy_Set.h"
00019 #include "tao/debug.h"
00020 #include "tao/CDR.h"
00021 #include "tao/SystemException.h"
00022 
00023 #include "ace/Dynamic_Service.h"
00024 #include "ace/OS_NS_string.h"
00025 
00026 ACE_RCSID (RTCORBA,
00027            RT_Protocols_Hooks,
00028            "$Id: RT_Protocols_Hooks.cpp 78627 2007-06-28 08:50:01Z johnnyw $")
00029 
00030 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00031 
00032 TAO_RT_Protocols_Hooks::TAO_RT_Protocols_Hooks (void)
00033   : orb_core_ (0)
00034   , current_ ()
00035 {
00036 }
00037 
00038 
00039 TAO_RT_Protocols_Hooks::~TAO_RT_Protocols_Hooks (void)
00040 {
00041 }
00042 
00043 void
00044 TAO_RT_Protocols_Hooks::init_hooks (TAO_ORB_Core *orb_core)
00045 {
00046   this->orb_core_ = orb_core;
00047 
00048   // Save a reference to the priority mapping manager.
00049   CORBA::Object_var obj =
00050     orb_core->object_ref_table ().resolve_initial_reference (
00051       TAO_OBJID_PRIORITYMAPPINGMANAGER);
00052 
00053   this->mapping_manager_ =
00054     TAO_Priority_Mapping_Manager::_narrow (obj.in ());
00055 
00056   // Save a reference to the priority mapping manager.
00057   CORBA::Object_var object =
00058     orb_core->object_ref_table ().resolve_initial_reference (
00059       TAO_OBJID_NETWORKPRIORITYMAPPINGMANAGER);
00060 
00061   this->network_mapping_manager_ =
00062     TAO_Network_Priority_Mapping_Manager::_narrow (object.in ());
00063 
00064   object =
00065     this->orb_core_->object_ref_table ().resolve_initial_reference (
00066       TAO_OBJID_RTCURRENT);
00067 
00068   this->current_ = RTCORBA::Current::_narrow (object.in ());
00069 
00070 }
00071 
00072 RTCORBA::ProtocolProperties_ptr
00073 TAO_RT_Protocols_Hooks::server_protocol_properties (IOP::ProfileId protocol_tag,
00074                                                     CORBA::Policy_ptr policy)
00075 {
00076   if (CORBA::is_nil (policy))
00077     return 0;
00078 
00079   RTCORBA::ServerProtocolPolicy_var server_protocol_policy =
00080     RTCORBA::ServerProtocolPolicy::_narrow (policy);
00081 
00082   if (CORBA::is_nil (server_protocol_policy.in ()))
00083     return 0;
00084 
00085   TAO_ServerProtocolPolicy *server_protocols =
00086     dynamic_cast<TAO_ServerProtocolPolicy *> (server_protocol_policy.in ());
00087 
00088   if (server_protocols == 0)
00089     return 0;
00090 
00091   // TAO_ServerProtocolPolicy
00092   RTCORBA::ProtocolList &protocols =
00093     server_protocols->protocols_rep ();
00094 
00095   for (CORBA::ULong j = 0; j < protocols.length (); ++j)
00096     {
00097       if (protocols[j].protocol_type == protocol_tag)
00098         {
00099           return RTCORBA::ProtocolProperties::_duplicate (
00100                   protocols[j].transport_protocol_properties.in ());
00101         }
00102     }
00103 
00104   return 0;
00105 }
00106 
00107 RTCORBA::ProtocolProperties_ptr
00108 TAO_RT_Protocols_Hooks::client_protocol_properties (IOP::ProfileId protocol_tag,
00109                                                     CORBA::Policy_ptr policy)
00110 {
00111   if (CORBA::is_nil (policy))
00112     return 0;
00113 
00114   RTCORBA::ClientProtocolPolicy_var client_protocol_policy =
00115     RTCORBA::ClientProtocolPolicy::_narrow (policy);
00116 
00117   if (CORBA::is_nil (client_protocol_policy.in ()))
00118     return 0;
00119 
00120   TAO_ClientProtocolPolicy *client_protocols =
00121     dynamic_cast<TAO_ClientProtocolPolicy *> (client_protocol_policy.in ());
00122 
00123   if (client_protocols == 0)
00124     return 0;
00125 
00126   // TAO_ClientProtocolPolicy
00127   RTCORBA::ProtocolList &protocols =
00128     client_protocols->protocols_rep ();
00129 
00130   for (CORBA::ULong j = 0; j < protocols.length (); ++j)
00131     {
00132       if (protocols[j].protocol_type == protocol_tag)
00133         {
00134           return RTCORBA::ProtocolProperties::_duplicate (
00135                   protocols[j].transport_protocol_properties.in ());
00136         }
00137     }
00138 
00139   return 0;
00140 }
00141 
00142 RTCORBA::ProtocolProperties_ptr
00143 TAO_RT_Protocols_Hooks::server_protocol_properties_at_orb_level (
00144   IOP::ProfileId protocol_tag)
00145 {
00146   CORBA::Policy_var policy =
00147     this->orb_core_->get_cached_policy (TAO_CACHED_POLICY_RT_SERVER_PROTOCOL);
00148 
00149   return this->server_protocol_properties (protocol_tag, policy.in ());
00150 }
00151 
00152 RTCORBA::ProtocolProperties_ptr
00153 TAO_RT_Protocols_Hooks::client_protocol_properties_at_orb_level (
00154   IOP::ProfileId protocol_tag)
00155 {
00156   CORBA::Policy_var policy =
00157     this->orb_core_->get_cached_policy (TAO_CACHED_POLICY_RT_CLIENT_PROTOCOL);
00158 
00159   return this->client_protocol_properties (protocol_tag, policy.in ());
00160 }
00161 
00162 RTCORBA::ProtocolProperties_ptr
00163 TAO_RT_Protocols_Hooks::client_protocol_properties_at_object_level (
00164   IOP::ProfileId protocol_tag,
00165   TAO_Stub *stub)
00166 {
00167   CORBA::Policy_var policy =
00168     stub->get_cached_policy (TAO_CACHED_POLICY_RT_CLIENT_PROTOCOL);
00169 
00170   return this->client_protocol_properties (protocol_tag, policy.in ());
00171 }
00172 
00173 void
00174 TAO_RT_Protocols_Hooks::extract_protocol_properties (TAO_IIOP_Protocol_Properties &to,
00175                                                      RTCORBA::ProtocolProperties_ptr from)
00176 {
00177   RTCORBA::TCPProtocolProperties_var protocol_properties =
00178     RTCORBA::TCPProtocolProperties::_narrow (from);
00179 
00180   to.send_buffer_size_ = protocol_properties->send_buffer_size ();
00181   to.recv_buffer_size_ = protocol_properties->recv_buffer_size ();
00182   to.keep_alive_ = protocol_properties->keep_alive ();
00183   to.dont_route_ = protocol_properties->dont_route ();
00184   to.no_delay_ = protocol_properties->no_delay ();
00185   to.enable_network_priority_ = protocol_properties->enable_network_priority ();
00186 }
00187 
00188 void
00189 TAO_RT_Protocols_Hooks::server_protocol_properties_at_orb_level (TAO_IIOP_Protocol_Properties &to)
00190 {
00191   RTCORBA::ProtocolProperties_var from =
00192     this->server_protocol_properties_at_orb_level (IOP::TAG_INTERNET_IOP);
00193 
00194   if (!CORBA::is_nil (from.in ()))
00195     this->extract_protocol_properties (to, from.in ());
00196 }
00197 
00198 void
00199 TAO_RT_Protocols_Hooks::client_protocol_properties_at_orb_level (TAO_IIOP_Protocol_Properties &to)
00200 {
00201   RTCORBA::ProtocolProperties_var from =
00202     this->client_protocol_properties_at_orb_level (IOP::TAG_INTERNET_IOP);
00203 
00204   if (!CORBA::is_nil (from.in ()))
00205     this->extract_protocol_properties (to, from.in ());
00206 }
00207 
00208 void
00209 TAO_RT_Protocols_Hooks::extract_protocol_properties (
00210   TAO_UIOP_Protocol_Properties &to,
00211   RTCORBA::ProtocolProperties_ptr from)
00212 {
00213   RTCORBA::UnixDomainProtocolProperties_var protocol_properties =
00214     RTCORBA::UnixDomainProtocolProperties::_narrow (from);
00215 
00216   to.send_buffer_size_ = protocol_properties->send_buffer_size ();
00217   to.recv_buffer_size_ = protocol_properties->recv_buffer_size ();
00218 }
00219 
00220 void
00221 TAO_RT_Protocols_Hooks::server_protocol_properties_at_orb_level (
00222   TAO_UIOP_Protocol_Properties &to)
00223 {
00224   RTCORBA::ProtocolProperties_var from =
00225     this->server_protocol_properties_at_orb_level (TAO_TAG_UIOP_PROFILE);
00226 
00227   if (!CORBA::is_nil (from.in ()))
00228     this->extract_protocol_properties (to, from.in ());
00229 }
00230 
00231 void
00232 TAO_RT_Protocols_Hooks::client_protocol_properties_at_orb_level (
00233   TAO_UIOP_Protocol_Properties &to)
00234 {
00235   RTCORBA::ProtocolProperties_var from =
00236     this->client_protocol_properties_at_orb_level (TAO_TAG_UIOP_PROFILE);
00237 
00238   if (!CORBA::is_nil (from.in ()))
00239     this->extract_protocol_properties (to, from.in ());
00240 }
00241 
00242 void
00243 TAO_RT_Protocols_Hooks::extract_protocol_properties (
00244   TAO_SHMIOP_Protocol_Properties &to,
00245   RTCORBA::ProtocolProperties_ptr from)
00246 {
00247   RTCORBA::SharedMemoryProtocolProperties_var protocol_properties =
00248     RTCORBA::SharedMemoryProtocolProperties::_narrow (from);
00249 
00250   to.preallocate_buffer_size_ = protocol_properties->preallocate_buffer_size ();
00251   to.mmap_filename_ = protocol_properties->mmap_filename ();
00252   to.mmap_lockname_ = protocol_properties->mmap_lockname ();
00253 }
00254 
00255 void
00256 TAO_RT_Protocols_Hooks::server_protocol_properties_at_orb_level (
00257   TAO_SHMIOP_Protocol_Properties &to)
00258 {
00259   RTCORBA::ProtocolProperties_var from =
00260     this->server_protocol_properties_at_orb_level (TAO_TAG_SHMEM_PROFILE);
00261 
00262   if (!CORBA::is_nil (from.in ()))
00263     this->extract_protocol_properties (to, from.in ());
00264 }
00265 
00266 void
00267 TAO_RT_Protocols_Hooks::client_protocol_properties_at_orb_level (
00268   TAO_SHMIOP_Protocol_Properties &to)
00269 {
00270   RTCORBA::ProtocolProperties_var from =
00271     this->client_protocol_properties_at_orb_level (TAO_TAG_SHMEM_PROFILE);
00272 
00273   if (!CORBA::is_nil (from.in ()))
00274     this->extract_protocol_properties (to, from.in ());
00275 }
00276 
00277 void
00278 TAO_RT_Protocols_Hooks::extract_protocol_properties (
00279   TAO_DIOP_Protocol_Properties &to,
00280   RTCORBA::ProtocolProperties_ptr from)
00281 {
00282   RTCORBA::UserDatagramProtocolProperties_var protocol_properties =
00283     RTCORBA::UserDatagramProtocolProperties::_narrow (from);
00284 
00285   to.enable_network_priority_ = protocol_properties->enable_network_priority ();
00286   to.send_buffer_size_ = protocol_properties->send_buffer_size ();
00287   to.recv_buffer_size_ = protocol_properties->recv_buffer_size ();
00288 }
00289 
00290 void
00291 TAO_RT_Protocols_Hooks::server_protocol_properties_at_orb_level (
00292   TAO_DIOP_Protocol_Properties &to)
00293 {
00294   RTCORBA::ProtocolProperties_var from =
00295     this->server_protocol_properties_at_orb_level (TAO_TAG_DIOP_PROFILE);
00296 
00297   if (!CORBA::is_nil (from.in ()))
00298     this->extract_protocol_properties (to, from.in ());
00299 }
00300 
00301 void
00302 TAO_RT_Protocols_Hooks::client_protocol_properties_at_orb_level (
00303   TAO_DIOP_Protocol_Properties &to)
00304 {
00305   RTCORBA::ProtocolProperties_var from =
00306     this->client_protocol_properties_at_orb_level (TAO_TAG_DIOP_PROFILE);
00307 
00308   if (!CORBA::is_nil (from.in ()))
00309     this->extract_protocol_properties (to, from.in ());
00310 }
00311 
00312 void
00313 TAO_RT_Protocols_Hooks::extract_protocol_properties (
00314   TAO_SCIOP_Protocol_Properties &to,
00315   RTCORBA::ProtocolProperties_ptr from)
00316 {
00317   RTCORBA::StreamControlProtocolProperties_var protocol_properties =
00318     RTCORBA::StreamControlProtocolProperties::_narrow (from);
00319 
00320   to.send_buffer_size_ = protocol_properties->send_buffer_size ();
00321   to.recv_buffer_size_ = protocol_properties->recv_buffer_size ();
00322   to.keep_alive_ = protocol_properties->keep_alive ();
00323   to.dont_route_ = protocol_properties->dont_route ();
00324   to.no_delay_ = protocol_properties->no_delay ();
00325   to.enable_network_priority_ = protocol_properties->enable_network_priority ();
00326 }
00327 
00328 void
00329 TAO_RT_Protocols_Hooks::server_protocol_properties_at_orb_level (
00330   TAO_SCIOP_Protocol_Properties &to)
00331 {
00332   RTCORBA::ProtocolProperties_var from =
00333     this->server_protocol_properties_at_orb_level (TAO_TAG_SCIOP_PROFILE);
00334 
00335   if (!CORBA::is_nil (from.in ()))
00336     this->extract_protocol_properties (to, from.in ());
00337 }
00338 
00339 void
00340 TAO_RT_Protocols_Hooks::client_protocol_properties_at_orb_level (
00341   TAO_SCIOP_Protocol_Properties &to)
00342 {
00343   RTCORBA::ProtocolProperties_var from =
00344     this->client_protocol_properties_at_orb_level (TAO_TAG_SCIOP_PROFILE);
00345 
00346   if (!CORBA::is_nil (from.in ()))
00347     this->extract_protocol_properties (to, from.in ());
00348 }
00349 
00350 CORBA::Boolean
00351 TAO_RT_Protocols_Hooks::set_network_priority (
00352   IOP::ProfileId protocol_tag,
00353   RTCORBA::ProtocolProperties_ptr protocol_properties)
00354 {
00355   if (CORBA::is_nil (protocol_properties))
00356       return false;
00357 
00358   if (protocol_tag == IOP::TAG_INTERNET_IOP)
00359     {
00360       RTCORBA::TCPProtocolProperties_var tcp_protocol_properties =
00361         RTCORBA::TCPProtocolProperties::_narrow (protocol_properties);
00362 
00363       return tcp_protocol_properties->enable_network_priority ();
00364     }
00365 
00366   if (protocol_tag == TAO_TAG_DIOP_PROFILE)
00367     {
00368       RTCORBA::UserDatagramProtocolProperties_var udp_protocol_properties =
00369         RTCORBA::UserDatagramProtocolProperties::_narrow (protocol_properties);
00370 
00371       return udp_protocol_properties->enable_network_priority ();
00372     }
00373 
00374   if (protocol_tag == TAO_TAG_SCIOP_PROFILE)
00375     {
00376       RTCORBA::StreamControlProtocolProperties_var sctp_protocol_properties =
00377         RTCORBA::StreamControlProtocolProperties::_narrow (protocol_properties);
00378 
00379       return sctp_protocol_properties->enable_network_priority ();
00380     }
00381 
00382   return false;
00383 }
00384 
00385 CORBA::Boolean
00386 TAO_RT_Protocols_Hooks::set_client_network_priority (IOP::ProfileId protocol_tag,
00387                                                      TAO_Stub *stub)
00388 {
00389   if (protocol_tag != IOP::TAG_INTERNET_IOP &&
00390       protocol_tag != TAO_TAG_DIOP_PROFILE &&
00391       protocol_tag != TAO_TAG_SCIOP_PROFILE)
00392     return false;
00393 
00394   RTCORBA::ProtocolProperties_var protocol_properties =
00395     this->client_protocol_properties_at_object_level (protocol_tag, stub);
00396 
00397   return this->set_network_priority (protocol_tag, protocol_properties.in ());
00398 }
00399 
00400 CORBA::Boolean
00401 TAO_RT_Protocols_Hooks::set_server_network_priority (IOP::ProfileId protocol_tag,
00402                                                      CORBA::Policy *policy)
00403 {
00404   if (protocol_tag != IOP::TAG_INTERNET_IOP &&
00405       protocol_tag != TAO_TAG_DIOP_PROFILE &&
00406       protocol_tag != TAO_TAG_SCIOP_PROFILE)
00407     return false;
00408 
00409   RTCORBA::ProtocolProperties_var protocol_properties =
00410     this->server_protocol_properties (protocol_tag, policy);
00411 
00412   return this->set_network_priority (protocol_tag, protocol_properties.in ());
00413 }
00414 
00415 CORBA::Long
00416 TAO_RT_Protocols_Hooks::get_dscp_codepoint (void)
00417 {
00418   if (TAO_debug_level)
00419     ACE_DEBUG ((LM_DEBUG,
00420                 "TAO_RT_Protocols_Hooks::get_dscp_codepoint\n"));
00421 
00422   CORBA::Long codepoint = 0;
00423 
00424   try
00425     {
00426       // Make several invocation, changing the priority of this thread
00427       // for each.
00428 
00429       RTCORBA::NetworkPriorityMapping *pm =
00430         this->network_mapping_manager_->mapping ();
00431 
00432       CORBA::Short const priority = this->current_->the_priority ();
00433 
00434       if (pm->to_network (priority, codepoint) == 0)
00435         {
00436           if (TAO_debug_level > 0)
00437             {
00438               ACE_ERROR ((LM_ERROR,
00439                           "Cannot convert corba priority %d "
00440                           "to network priority\n",
00441                           priority));
00442             }
00443 
00444           return -1;
00445         }
00446     }
00447   catch (const ::CORBA::Exception& ex)
00448     {
00449       if (TAO_debug_level > 0)
00450         {
00451           ex._tao_print_exception (
00452             "TAO_RT_Protocols_Hooks::get_dscp_codepoint");
00453         }
00454 
00455       return -1;
00456     }
00457 
00458   return codepoint;
00459 }
00460 
00461 void
00462 TAO_RT_Protocols_Hooks::rt_service_context (
00463     TAO_Stub *stub,
00464     TAO_Service_Context &service_context,
00465     CORBA::Boolean restart)
00466 {
00467   // If the restart flag is true, then this call for a
00468   // reinvocation. We need not prepare the Service Context List once
00469   // again. We can use the already existing one.
00470   if (!restart)
00471     {
00472       TAO_RT_Stub *rt_stub =
00473         dynamic_cast<TAO_RT_Stub *> (stub);
00474 
00475       if (!rt_stub)
00476         throw CORBA::INTERNAL ();
00477 
00478       CORBA::Policy_var priority_model_policy =
00479         rt_stub->get_cached_policy (TAO_CACHED_POLICY_PRIORITY_MODEL);
00480 
00481       if (!CORBA::is_nil (priority_model_policy.in ()))
00482         {
00483           CORBA::Short client_priority;
00484 
00485           int const status =
00486             this->get_thread_CORBA_priority (client_priority);
00487 
00488           if (status == -1)
00489             throw ::CORBA::DATA_CONVERSION (1, CORBA::COMPLETED_NO);
00490 
00491           this->add_rt_service_context_hook (service_context,
00492                                              priority_model_policy.in (),
00493                                              client_priority);
00494         }
00495       else
00496         {
00497           // The Object does not contain PriorityModel policy in its IOR.
00498           // We must be talking to a non-RT ORB.  Do nothing.
00499         }
00500     }
00501 }
00502 
00503 void
00504 TAO_RT_Protocols_Hooks::add_rt_service_context_hook (
00505     TAO_Service_Context &service_context,
00506     CORBA::Policy *model_policy,
00507     CORBA::Short &client_priority
00508 
00509   )
00510 {
00511   RTCORBA::PriorityModelPolicy_var model_policy_ptr =
00512     RTCORBA::PriorityModelPolicy::_narrow (model_policy);
00513 
00514   TAO_PriorityModelPolicy *priority_model =
00515     static_cast<TAO_PriorityModelPolicy *> (model_policy_ptr.in ());
00516 
00517   if (priority_model->get_priority_model () == RTCORBA::CLIENT_PROPAGATED)
00518     {
00519       // Encapsulate the priority of the current thread into
00520       // a service context.
00521       TAO_OutputCDR cdr;
00522       if ((cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER) == 0)
00523           || (cdr << client_priority) == 0)
00524         {
00525           throw ::CORBA::MARSHAL ();
00526         }
00527 
00528       service_context.set_context (IOP::RTCorbaPriority, cdr);
00529     }
00530 }
00531 
00532 void
00533 TAO_RT_Protocols_Hooks::get_selector_hook (
00534     CORBA::Policy *model_policy,
00535     CORBA::Boolean &is_client_propagated,
00536     CORBA::Short &server_priority)
00537 {
00538   RTCORBA::PriorityModelPolicy_var model_policy_ptr =
00539     RTCORBA::PriorityModelPolicy::_narrow (model_policy);
00540 
00541   TAO_PriorityModelPolicy *priority_model_policy =
00542     static_cast<TAO_PriorityModelPolicy *> (model_policy_ptr.in ());
00543 
00544   if (priority_model_policy->get_priority_model () == RTCORBA::CLIENT_PROPAGATED)
00545     {
00546       is_client_propagated = true;
00547     }
00548 
00549   if (!is_client_propagated)
00550     {
00551       server_priority = priority_model_policy->server_priority ();
00552     }
00553 
00554   return;
00555 }
00556 
00557 void
00558 TAO_RT_Protocols_Hooks::get_selector_bands_policy_hook (
00559     CORBA::Policy *bands_policy,
00560     CORBA::Short priority,
00561     CORBA::Short &min_priority,
00562     CORBA::Short &max_priority,
00563     bool &in_range
00564   )
00565 {
00566   RTCORBA::PriorityBandedConnectionPolicy_var bands_policy_ptr =
00567     RTCORBA::PriorityBandedConnectionPolicy::_narrow (bands_policy);
00568 
00569   TAO_PriorityBandedConnectionPolicy *priority_bands_policy =
00570     static_cast<TAO_PriorityBandedConnectionPolicy *> (bands_policy_ptr.in ());
00571 
00572   // Find the band with the range covering our target priority.
00573   RTCORBA::PriorityBands &bands =
00574     priority_bands_policy->priority_bands_rep ();
00575 
00576   for (CORBA::ULong i = 0; i < bands.length (); ++i)
00577     {
00578       if (bands[i].low <= priority && bands[i].high >= priority)
00579         {
00580           min_priority = bands[i].low;
00581           max_priority = bands[i].high;
00582 
00583           in_range = true;
00584           break;
00585         }
00586     }
00587 }
00588 
00589 int
00590 TAO_RT_Protocols_Hooks::get_thread_CORBA_priority (CORBA::Short &priority)
00591 {
00592   CORBA::Short native_priority = 0;
00593 
00594   if (this->get_thread_CORBA_and_native_priority (priority, native_priority) == -1)
00595     {
00596       return -1;
00597     }
00598 
00599   return 0;
00600 }
00601 
00602 int
00603 TAO_RT_Protocols_Hooks::get_thread_native_priority (
00604     CORBA::Short &native_priority)
00605 {
00606   ACE_hthread_t current;
00607   ACE_Thread::self (current);
00608 
00609   int priority;
00610 
00611   if (ACE_Thread::getprio (current, priority) == -1)
00612     {
00613       ACE_DEBUG ((LM_DEBUG,
00614                   ACE_TEXT ("TAO (%P|%t) - ")
00615                   ACE_TEXT ("RT_Protocols_Hooks::get_thread_priority: ")
00616                   ACE_TEXT (" ACE_Thread::get_prio\n")));
00617 
00618       return -1;
00619     }
00620 
00621   native_priority = CORBA::Short (priority);
00622   return 0;
00623 }
00624 
00625 int
00626 TAO_RT_Protocols_Hooks::get_thread_CORBA_and_native_priority (
00627     CORBA::Short &priority,
00628     CORBA::Short &native_priority)
00629 {
00630   if (this->get_thread_native_priority (native_priority) == -1)
00631     {
00632       return -1;
00633     }
00634 
00635   TAO_Priority_Mapping *priority_mapping =
00636     this->mapping_manager_.in ()->mapping ();
00637 
00638   if (priority_mapping->to_CORBA (native_priority, priority) == 0)
00639     {
00640       ACE_DEBUG ((LM_DEBUG,
00641                   ACE_TEXT ("TAO (%P|%t) - ")
00642                   ACE_TEXT ("RT_Protocols_Hooks::get_thread_priority: ")
00643                   ACE_TEXT ("Priority_Mapping::to_CORBA\n")));
00644       return -1;
00645     }
00646 
00647   return 0;
00648 }
00649 
00650 int
00651 TAO_RT_Protocols_Hooks::set_thread_CORBA_priority (CORBA::Short priority)
00652 {
00653   TAO_Priority_Mapping *priority_mapping =
00654     this->mapping_manager_.in ()->mapping ();
00655 
00656   CORBA::Short native_priority;
00657 
00658   if (priority_mapping->to_native (priority, native_priority) == 0)
00659     {
00660       return -1;
00661     }
00662 
00663   return this->set_thread_native_priority (native_priority);
00664 }
00665 
00666 int
00667 TAO_RT_Protocols_Hooks::set_thread_native_priority (
00668   CORBA::Short native_priority)
00669 {
00670   ACE_hthread_t current;
00671   ACE_Thread::self (current);
00672 
00673   if (ACE_Thread::setprio (current, native_priority) == -1)
00674     {
00675       ACE_ERROR_RETURN ((LM_ERROR,
00676                          ACE_TEXT ("(%N,%l) Error setting thread ")
00677                          ACE_TEXT ("priority to %d, errno %d %m\n"),
00678                          native_priority,
00679                          errno ),
00680                        -1);
00681     }
00682 
00683   return 0;
00684 }
00685 
00686 TAO_END_VERSIONED_NAMESPACE_DECL
00687 
00688 ACE_STATIC_SVC_DEFINE (TAO_RT_Protocols_Hooks,
00689                        ACE_TEXT ("RT_Protocols_Hooks"),
00690                        ACE_SVC_OBJ_T,
00691                        &ACE_SVC_NAME (TAO_RT_Protocols_Hooks),
00692                        ACE_Service_Type::DELETE_THIS
00693                        | ACE_Service_Type::DELETE_OBJ,
00694                        0)
00695 ACE_FACTORY_DEFINE (TAO_RTCORBA, TAO_RT_Protocols_Hooks)
00696 
00697 #endif /* TAO_HAS_CORBA_MESSAGING && TAO_HAS_CORBA_MESSAGING != 0 */

Generated on Tue Feb 2 17:42:49 2010 for TAO_RTCORBA by  doxygen 1.4.7