Merge pull request #2301 from sonndinh/remove-dup-reactor-functions
[ACE_TAO.git] / TAO / tao / Transport_Selection_Guard.cpp
blobcd79ab92d66c6b1de34d60e1bbe160df6c3de758
1 // -*- C++ -*-
2 #include "tao/Transport_Selection_Guard.h"
3 #include "tao/TSS_Resources.h"
5 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
7 namespace TAO
9 Transport_Selection_Guard*
10 Transport_Selection_Guard::current (TAO_ORB_Core* core, size_t tss_slot_id)
12 // @NOTE: (Iliyan) Started making this method aware of the core
13 // and the tss slot that correspond to the "current" transport,
14 // influenced by a general design preference to keep things
15 // local. The idea was to make the current TSG part of the TSS
16 // storage for a specific ORB Core, as opposed to using the global
17 // TSS Resources. However, it really doesn't offer any benefit to
18 // store a Transport pointer locally, for each ORB. There is
19 // always only one current Transport per thread. Period. The
20 // number of ORB Core instances in existence does not change that
21 // fact, so keeping a separate pointer would have been an
22 // over-kill.
23 ACE_UNUSED_ARG (core);
24 ACE_UNUSED_ARG (tss_slot_id);
26 #if TAO_HAS_TRANSPORT_CURRENT == 1
27 return TAO_TSS_Resources::instance ()->tsg_;
28 #else /* TAO_HAS_TRANSPORT_CURRENT != 1 */
29 return 0;
30 #endif /* TAO_HAS_TRANSPORT_CURRENT == 1 */
33 /// Ctor
34 Transport_Selection_Guard::Transport_Selection_Guard (TAO_Transport* t)
36 #if TAO_HAS_TRANSPORT_CURRENT == 1
37 prev_ (TAO_TSS_Resources::instance ()->tsg_) ,
38 #endif /* TAO_HAS_TRANSPORT_CURRENT == 1 */
39 curr_ (t)
41 #if TAO_HAS_TRANSPORT_CURRENT == 1
42 TAO_TSS_Resources::instance ()->tsg_ = this;
43 #endif /* TAO_HAS_TRANSPORT_CURRENT == 1 */
46 /// Dtor
47 Transport_Selection_Guard::~Transport_Selection_Guard ()
49 #if TAO_HAS_TRANSPORT_CURRENT == 1
50 TAO_TSS_Resources::instance ()->tsg_ = prev_;
51 this->prev_ = nullptr;
52 #endif /* TAO_HAS_TRANSPORT_CURRENT == 1 */
53 this->curr_ = nullptr;
56 bool
57 operator== (const Transport_Selection_Guard& lhs,
58 const TAO_Transport* rhs)
60 return lhs.curr_ == rhs;
63 bool
64 operator== (const TAO_Transport* lhs,
65 const Transport_Selection_Guard& rhs)
67 return lhs == rhs.curr_;
70 bool
71 operator!= (const Transport_Selection_Guard& lhs,
72 const TAO_Transport* rhs)
74 return lhs.curr_ != rhs;
77 bool
78 operator!= (const TAO_Transport* lhs,
79 const Transport_Selection_Guard& rhs)
81 return lhs != rhs.curr_;
83 } /* namespace TAO */
85 TAO_END_VERSIONED_NAMESPACE_DECL