TAO::PICurrent_Guard Class Reference

Class used to make copying between request scope current and thread scope current exception-safe. More...

#include <PICurrent_Guard.h>

List of all members.

Public Member Functions

 PICurrent_Guard (TAO_ServerRequest &server_request, bool tsc_to_rsc)
 Constructor.

 ~PICurrent_Guard (void)
 Destructor.


Private Attributes

PICurrent_Impl * src_
 The PICurrent implementation whose slot table will be copied.

PICurrent_Impl * dest_


Detailed Description

Class used to make copying between request scope current and thread scope current exception-safe.

Since copies between the request scope current and thread scope current must also occur if an exception is thrown, e.g. made available to the send_exception() interception points, the "guard" idiom is used to make this action exception-safe.

Note:
This Guard class is only used on the server side.

Definition at line 50 of file PICurrent_Guard.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO::PICurrent_Guard::PICurrent_Guard TAO_ServerRequest server_request,
bool  tsc_to_rsc
 

Constructor.

This constructor sets up this guard to copy the data held in a given PICurrent when transitioning from that PICurrent's scope to another scope (e.g. request scope to thread scope transition immediately following receive_request_service_contexts() on server side).

Parameters:
tsc_to_rsc true when copying TSC slot table to RSC slot table, i.e. after target operation completes.

Definition at line 18 of file PICurrent_Guard.cpp.

References dest_, TAO_ServerRequest::orb_core(), TAO_ORB_Core::pi_current(), TAO_ServerRequest::rs_pi_current(), and src_.

00020   : src_ (0),
00021     dest_ (0)
00022 {
00023   // This constructor is used on the server side.
00024 
00025   // Retrieve the thread scope current (no TSS access incurred yet).
00026   CORBA::Object_ptr pi_current_obj =
00027     server_request.orb_core ()->pi_current ();
00028 
00029   TAO::PICurrent *pi_current =
00030     dynamic_cast <TAO::PICurrent*> (pi_current_obj);
00031 
00032   // If the slot count is zero, there is nothing to copy.  Prevent any
00033   // copying (and hence TSS accesses) from occurring.
00034   if (pi_current != 0 && pi_current->slot_count () != 0)
00035     {
00036       // Retrieve the request scope current.
00037       PICurrent_Impl * rsc = server_request.rs_pi_current ();
00038 
00039       // Retrieve the thread scope current.
00040       PICurrent_Impl * tsc = pi_current->tsc ();
00041 
00042       if (tsc_to_rsc)
00043         {
00044           // TSC to RSC copy.
00045           // Occurs after receive_request() interception point and
00046           // upcall.
00047           this->src_  = tsc;
00048           this->dest_ = rsc;
00049         }
00050       else
00051         {
00052           // RSC to TSC copy.
00053           // Occurs after receive_request_service_contexts()
00054           // interception point.
00055           this->src_  = rsc;
00056           this->dest_ = tsc;
00057         }
00058     }
00059 }

TAO::PICurrent_Guard::~PICurrent_Guard void   ) 
 

Destructor.

The destructor copies (a logical copy whenever possible) data held in a given PICurrent when transitioning from one PICurrent scope to another immediately before any ending interception points are invoked, and after the starting and intermediate (if any) interception points are invoked.

Definition at line 61 of file PICurrent_Guard.cpp.

References dest_, and src_.

00062 {
00063   if (this->src_ != 0 && this->dest_ != 0
00064       && this->src_ != this->dest_)
00065     {
00066       this->dest_->take_lazy_copy (this->src_);
00067     }
00068 }


Member Data Documentation

PICurrent_Impl* TAO::PICurrent_Guard::dest_ [private]
 

The PICurrent implementation whose slot table will be filled with the contents of another PICurrent's slot table.

Definition at line 86 of file PICurrent_Guard.h.

Referenced by PICurrent_Guard(), and ~PICurrent_Guard().

PICurrent_Impl* TAO::PICurrent_Guard::src_ [private]
 

The PICurrent implementation whose slot table will be copied.

Definition at line 82 of file PICurrent_Guard.h.

Referenced by PICurrent_Guard(), and ~PICurrent_Guard().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 12:54:33 2006 for TAO_PI_Server by doxygen 1.3.6