Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

TAO_PICurrent_Guard Class Reference

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

#include <PICurrent.h>

Collaboration diagram for TAO_PICurrent_Guard:

Collaboration graph
[legend]
List of all members.

Public Methods

 TAO_PICurrent_Guard (TAO_ServerRequest &server_request, CORBA::Boolean tsc_to_rsc)
 Constructor. More...

 ~TAO_PICurrent_Guard (void)
 Destructor. More...


Private Attributes

TAO_PICurrent_Implsrc_
 The PICurrent implementation whose slot table will copied. More...

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

CORBA::Boolean tsc_to_rsc_
 Flag that indicates if the TSC is to be copied to the RSC. More...


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 258 of file PICurrent.h.


Constructor & Destructor Documentation

TAO_PICurrent_Guard::TAO_PICurrent_Guard TAO_ServerRequest   server_request,
CORBA::Boolean    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).

Definition at line 249 of file PICurrent.cpp.

References dest_, TAO_ServerRequest::orb_core, TAO_ORB_Core::pi_current, TAO_ServerRequest::rs_pi_current, TAO_PICurrent::slot_count, src_, and TAO_PICurrent::tsc.

00251   : src_ (0),
00252     dest_ (0),
00253     tsc_to_rsc_ (tsc_to_rsc)
00254 {
00255   // This constructor is used on the server side.
00256 
00257   // Retrieve the thread scope current (no TSS access incurred yet).
00258   TAO_PICurrent *pi_current = server_request.orb_core ()->pi_current ();
00259 
00260   // If the slot count is zero, then there is nothing to copy.
00261   // Prevent any copying (and hence TSS accesses) from occurring.
00262   if (pi_current != 0 && pi_current->slot_count () != 0)
00263     {
00264       // Retrieve the request scope current.
00265       TAO_PICurrent_Impl *rsc = &server_request.rs_pi_current ();
00266 
00267       // Retrieve the thread scope current.
00268       TAO_PICurrent_Impl *tsc = pi_current->tsc ();
00269 
00270       if (tsc_to_rsc)
00271         {
00272           // TSC to RSC copy.
00273           // Occurs after receive_request() interception point and
00274           // upcall.
00275           this->src_  = tsc;
00276           this->dest_ = rsc;
00277         }
00278       else
00279         {
00280           // RSC to TSC copy.
00281           // Occurs after receive_request_service_contexts()
00282           // interception point.
00283           this->src_  = rsc;
00284           this->dest_ = tsc;
00285         }
00286     }
00287 }

TAO_PICurrent_Guard::~TAO_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 sending and intermediate (if any) interception points are invoked.

Definition at line 289 of file PICurrent.cpp.

References TAO_PICurrent_Impl::copy, dest_, TAO_PICurrent_Impl::pi_peer, src_, and tsc_to_rsc_.

00290 {
00291   if (this->src_ != 0 && this->dest_ != 0)
00292     {
00293       // This copy better be exception-safe!
00294       this->dest_->copy (*this->src_, 0);    // Logical copy
00295 
00296       // PICurrent will potentially have to call back on the request
00297       // scope current so that it can deep copy the contents of the
00298       // thread scope current if the contents of the thread scope
00299       // current are about to be modified.  It is necessary to do this
00300       // deep copy once in order to completely isolate the request
00301       // scope current from the thread scope current.  This is only
00302       // necessary, if the thread scope current is modified after its
00303       // contents have been *logically* copied to the request scope
00304       // current.
00305       //
00306       // source:      TSC
00307       // destination: RSC
00308       if (this->tsc_to_rsc_)
00309         this->src_->pi_peer (this->dest_);
00310     }
00311 }


Member Data Documentation

TAO_PICurrent_Impl* TAO_PICurrent_Guard::dest_ [private]
 

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

Definition at line 290 of file PICurrent.h.

Referenced by TAO_PICurrent_Guard, and ~TAO_PICurrent_Guard.

TAO_PICurrent_Impl* TAO_PICurrent_Guard::src_ [private]
 

The PICurrent implementation whose slot table will copied.

Definition at line 286 of file PICurrent.h.

Referenced by TAO_PICurrent_Guard, and ~TAO_PICurrent_Guard.

CORBA::Boolean TAO_PICurrent_Guard::tsc_to_rsc_ [private]
 

Flag that indicates if the TSC is to be copied to the RSC.

If false, then the RSC must be deep copied upon leaving the request scope and entering the thread scope. This is necessary since the RSC slot table is no longer available upon leaving the thread scope, meaning that a logical copy is not enough.

Definition at line 299 of file PICurrent.h.

Referenced by ~TAO_PICurrent_Guard.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 15:33:27 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002