Merge pull request #2301 from sonndinh/remove-dup-reactor-functions
[ACE_TAO.git] / TAO / tao / PI_Server / PICurrent_Guard.cpp
blob61f12fffadf92eb10fca98ae27f72fc4e84c206f
1 // -*- C++ -*-
2 #include "tao/PI_Server/PICurrent_Guard.h"
4 #if TAO_HAS_INTERCEPTORS == 1
6 #include "tao/ORB_Core.h"
7 #include "tao/TAO_Server_Request.h"
8 #include "tao/PI/PICurrent.h"
9 #include "tao/PI/PICurrent_Impl.h"
11 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
13 TAO::PICurrent_Guard::PICurrent_Guard (TAO_ServerRequest &server_request,
14 bool tsc_to_rsc)
15 : src_ (0),
16 dest_ (0)
18 // This constructor is used on the server side.
20 // Retrieve the thread scope current (no TSS access incurred yet).
21 CORBA::Object_ptr pi_current_obj =
22 server_request.orb_core ()->pi_current ();
24 TAO::PICurrent *pi_current =
25 dynamic_cast <TAO::PICurrent*> (pi_current_obj);
27 // If the slot count is zero, there is nothing to copy. Prevent any
28 // copying (and hence TSS accesses) from occurring.
29 if (pi_current != 0 && pi_current->slot_count () != 0)
31 // Retrieve the request scope current.
32 PICurrent_Impl * rsc = server_request.rs_pi_current ();
34 // Retrieve the thread scope current.
35 PICurrent_Impl * tsc = pi_current->tsc ();
37 if (tsc_to_rsc)
39 // TSC to RSC copy.
40 // Occurs after receive_request() interception point and
41 // upcall.
42 this->src_ = tsc;
43 this->dest_ = rsc;
45 else
47 // RSC to TSC copy.
48 // Occurs after receive_request_service_contexts()
49 // interception point.
50 this->src_ = rsc;
51 this->dest_ = tsc;
56 TAO::PICurrent_Guard::~PICurrent_Guard ()
58 if (this->src_ != 0 && this->dest_ != 0
59 && this->src_ != this->dest_)
61 this->dest_->take_lazy_copy (this->src_);
65 TAO_END_VERSIONED_NAMESPACE_DECL
67 #endif /* TAO_HAS_INTERCEPTORS == 1 */