summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Endpoint_Selector_Factory.cpp
blob: dc4a86e888372af18feb9a6efde79293e166114f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "orbsvcs/FaultTolerance/FT_Endpoint_Selector_Factory.h"
#include "orbsvcs/FaultTolerance/FT_Invocation_Endpoint_Selectors.h"
#include "tao/SystemException.h"

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

TAO_FT_Endpoint_Selector_Factory::TAO_FT_Endpoint_Selector_Factory ()
  : ft_endpoint_selector_ (0)
{
}

TAO_FT_Endpoint_Selector_Factory::~TAO_FT_Endpoint_Selector_Factory ()
{
  delete this->ft_endpoint_selector_;
}


TAO_Invocation_Endpoint_Selector *
TAO_FT_Endpoint_Selector_Factory::get_selector ()
{
    if (this->ft_endpoint_selector_ == 0)
    {
      ACE_MT (ACE_GUARD_RETURN  (TAO_SYNCH_MUTEX,
                                 guard,
                                 this->mutex_,
                                 0));

      // Double checked locking..
      if (this->ft_endpoint_selector_ == 0)
        {
          ACE_NEW_THROW_EX (ft_endpoint_selector_,
                            TAO_FT_Invocation_Endpoint_Selector (),
                            CORBA::NO_MEMORY ());
        }
    }

  return this->ft_endpoint_selector_;
}

TAO_END_VERSIONED_NAMESPACE_DECL

// ****************************************************************

ACE_STATIC_SVC_DEFINE (TAO_FT_Endpoint_Selector_Factory,
                       ACE_TEXT ("FT_Endpoint_Selector_Factory"),
                       ACE_SVC_OBJ_T,
                       &ACE_SVC_NAME (TAO_FT_Endpoint_Selector_Factory),
                       ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,
                       0)
ACE_FACTORY_DEFINE (TAO_FT_ClientORB, TAO_FT_Endpoint_Selector_Factory)