summaryrefslogtreecommitdiff
path: root/TAO/tao/RTPortableServer/RT_Servant_Dispatcher.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/tao/RTPortableServer/RT_Servant_Dispatcher.cpp')
-rw-r--r--TAO/tao/RTPortableServer/RT_Servant_Dispatcher.cpp181
1 files changed, 117 insertions, 64 deletions
diff --git a/TAO/tao/RTPortableServer/RT_Servant_Dispatcher.cpp b/TAO/tao/RTPortableServer/RT_Servant_Dispatcher.cpp
index 3446163b628..b7bb51f6879 100644
--- a/TAO/tao/RTPortableServer/RT_Servant_Dispatcher.cpp
+++ b/TAO/tao/RTPortableServer/RT_Servant_Dispatcher.cpp
@@ -2,6 +2,7 @@
#include "RT_Servant_Dispatcher.h"
#include "RT_POA.h"
+#include "tao/RTCORBA/Thread_Pool.h"
#include "tao/ORB_Core.h"
#include "tao/TAO_Server_Request.h"
#include "tao/Service_Context.h"
@@ -9,34 +10,33 @@
ACE_RCSID(tao, Default_Acceptor_Filter, "$Id$")
-RT_Priority_Model_Processing::RT_Priority_Model_Processing (TAO_POA &poa)
+RT_Priority_Model_Processing::RT_Priority_Model_Processing (TAO_POA &poa,
+ CORBA::Short servant_priority)
: state_ (NO_ACTION_REQUIRED),
poa_ (poa),
- original_priority_ (0)
+ servant_priority_ (servant_priority),
+ original_priority_ (TAO_INVALID_PRIORITY)
{
}
RT_Priority_Model_Processing::~RT_Priority_Model_Processing (void)
{
- ACE_DECLARE_NEW_CORBA_ENV;
-
if (this->state_ == PRIORITY_RESET_REQUIRED)
{
- this->state_ = NO_ACTION_REQUIRED;
-
- // Reset the priority of the current thread back to its original
- // value.
- TAO_Protocols_Hooks *tph = poa_.orb_core ().get_protocols_hooks (ACE_TRY_ENV);
- ACE_CHECK;
+ ACE_DECLARE_NEW_CORBA_ENV;
- if (tph->set_thread_priority (this->original_priority_,
- ACE_TRY_ENV)
- == -1)
- // At this point we cannot throw an exception. Just log the
- // error.
- ACE_DEBUG ((LM_ERROR,
- ACE_TEXT ("TAO (%P|%t) - Priority_Model_Processing:: ")
- ACE_TEXT (" Priority_Model_Processing\n")));
+ ACE_TRY
+ {
+ this->post_invoke (ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+ }
+ ACE_CATCHANY
+ {
+ // Eat up the exception.
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "Exception caught: TAO (%P|%t) - Priority_Model_Processing::~Priority_Model_Processing");
+ }
+ ACE_ENDTRY;
}
}
@@ -46,25 +46,61 @@ RT_Priority_Model_Processing::pre_invoke (
TAO_Service_Context &reply_service_context,
CORBA::Environment &ACE_TRY_ENV)
{
- TAO_POA_Cached_Policies &cached_policies = this->poa_.cached_policies ();
+ TAO_Thread_Pool *thread_pool =
+ (TAO_Thread_Pool *) this->poa_.thread_pool ();
- // CLIENT_PROPAGATED PriorityModel processing.
- if (cached_policies.priority_model () == TAO_POA_Cached_Policies::CLIENT_PROPAGATED
- && cached_policies.server_priority () != TAO_INVALID_PRIORITY)
+ if (thread_pool != 0 &&
+ thread_pool->with_lanes ())
{
- // Remember current thread's priority.
- TAO_Protocols_Hooks *tph = poa_.orb_core ().get_protocols_hooks (ACE_TRY_ENV);
- ACE_CHECK;
+ // We don't mess with the priority of threads in lanes.
- if (tph->get_thread_priority (this->original_priority_,
- ACE_TRY_ENV)
- == -1)
- ACE_THROW (CORBA::DATA_CONVERSION (1,
- CORBA::COMPLETED_NO));
+ if (TAO_debug_level > 0)
+ {
+ // Get the ORB_Core's TSS resources.
+ TAO_ORB_Core_TSS_Resources *tss =
+ this->poa_.orb_core ().get_tss_resources ();
+
+ /// Get the lane attribute in TSS.
+ TAO_Thread_Lane *lane =
+ (TAO_Thread_Lane *) tss->lane_;
+
+ ACE_ASSERT (lane->pool ().id () ==
+ thread_pool->id ());
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Using thread pool with lane ")
+ ACE_TEXT ("(%P|%t|%d|%d): original thread priority not changed\n"),
+ lane->pool ().id (),
+ lane->id ()));
+ }
+
+ return;
+ }
+
+ // Remember current thread's priority.
+ TAO_Protocols_Hooks *tph =
+ this->poa_.orb_core ().get_protocols_hooks (ACE_TRY_ENV);
+ ACE_CHECK;
+
+ if (tph->get_thread_priority (this->original_priority_,
+ ACE_TRY_ENV)
+ == -1)
+ ACE_THROW (CORBA::DATA_CONVERSION (1,
+ CORBA::COMPLETED_NO));
+
+ int client_propagated = 0;
+ RTCORBA::Priority target_priority = TAO_INVALID_PRIORITY;
+ TAO_POA_Cached_Policies &cached_policies =
+ this->poa_.cached_policies ();
+
+ // CLIENT_PROPAGATED PriorityModel processing.
+ if (cached_policies.priority_model () ==
+ TAO_POA_Cached_Policies::CLIENT_PROPAGATED)
+ {
+ client_propagated = 1;
// Attempt to extract client-propagated priority from the
- // ServiceContextList of the request.
- RTCORBA::Priority target_priority;
+ // ServiceContextList of the request.
const IOP::ServiceContext *context;
if (request_service_context.get_context (IOP::RTCorbaPriority,
@@ -90,37 +126,54 @@ RT_Priority_Model_Processing::pre_invoke (
}
else
{
- // Use default priority if none came in the request. (Request
- // must have come from a non-RT ORB.)
+ // Use default priority if none came in the request.
+ // (Request must have come from a non-RT ORB.)
target_priority = cached_policies.server_priority ();
}
+ }
+ else
+ // SERVER_DECLARED PriorityModel processing.
+ {
+ // Use the request associated with the servant.
+ target_priority = this->servant_priority_;
+ }
+
+ const char *priority_model;
+ if (client_propagated)
+ priority_model = "RTCORBA::CLIENT_PROPAGATED";
+ else
+ priority_model = "RTCORBA::SERVER_DECLARED";
- // Change the priority of the current thread to the
- // client-propagated value for the duration of
- // request.
- if (original_priority_ != target_priority)
+ // Change the priority of the current thread for the duration of
+ // request.
+ if (target_priority != TAO_INVALID_PRIORITY &&
+ target_priority != this->original_priority_)
+ {
+ if (TAO_debug_level > 0)
{
- if (TAO_debug_level > 0)
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("RTCORBA::CLIENT_PROPAGATED processing")
- ACE_TEXT (" (%P|%t): original thread priority %d")
- ACE_TEXT (" temporarily changed to %d\n"),
- original_priority_, target_priority));
-
- if (tph->set_thread_priority (target_priority,
- ACE_TRY_ENV)
- == -1)
- ACE_THROW (CORBA::DATA_CONVERSION (1, CORBA::COMPLETED_NO));
-
- this->state_ = PRIORITY_RESET_REQUIRED;
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("%s processing ")
+ ACE_TEXT ("(%P|%t): original thread priority %d ")
+ ACE_TEXT ("temporarily changed to %d\n"),
+ priority_model,
+ original_priority_,
+ target_priority));
}
- else if (TAO_debug_level > 0)
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("RTCORBA::CLIENT_PROPAGATED processing")
- ACE_TEXT (" (%P|%t): original thread priority =")
- ACE_TEXT (" requested priority = %d\n"),
- target_priority));
+
+ if (tph->set_thread_priority (target_priority,
+ ACE_TRY_ENV)
+ == -1)
+ ACE_THROW (CORBA::DATA_CONVERSION (1, CORBA::COMPLETED_NO));
+
+ this->state_ = PRIORITY_RESET_REQUIRED;
}
+ else if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("%s processing ")
+ ACE_TEXT ("(%P|%t): original thread priority = ")
+ ACE_TEXT ("target priority = %d\n"),
+ priority_model,
+ target_priority));
}
void
@@ -133,7 +186,8 @@ RT_Priority_Model_Processing::post_invoke (
// Reset the priority of the current thread back to its original
// value.
- TAO_Protocols_Hooks *tph = poa_.orb_core ().get_protocols_hooks (ACE_TRY_ENV);
+ TAO_Protocols_Hooks *tph =
+ this->poa_.orb_core ().get_protocols_hooks (ACE_TRY_ENV);
ACE_CHECK;
if (tph->set_thread_priority (this->original_priority_,
@@ -155,11 +209,11 @@ TAO_RT_Servant_Dispatcher::dispatch (TAO_Object_Adapter::Servant_Upcall &servant
CORBA::Environment &ACE_TRY_ENV)
{
// RTCORBA PriorityModelPolicy processing (may need to be
- // moved/adjusted when POA threadpools are added).
- // This is the earliest place we can do the processing, since only
- // at this point we know the target POA.
-
- RT_Priority_Model_Processing priority_processing (servant_upcall.poa ());
+ // moved/adjusted when POA threadpools are added). This is the
+ // earliest place we can do the processing, since only at this point
+ // we know the target POA.
+ RT_Priority_Model_Processing priority_processing (servant_upcall.poa (),
+ servant_upcall.priority ());
// Set thread's priority.
priority_processing.pre_invoke (req.request_service_context (),
@@ -208,4 +262,3 @@ TAO_RT_Servant_Dispatcher::create_POA (const ACE_CString &name,
return poa;
}
-