summaryrefslogtreecommitdiff
path: root/TAO/IIOP/lib/factories.cpp
blob: 987959124347818b8738b00619db0f21bb2642cc (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include "factories.h"

#if !defined(__ACE_INLINE__)
#  include "factories.i"
#endif

int
TAO_Client_Connection_Handler::open(void *)
{
  // Here is where we could enable all sorts of things such as
  // nonblock I/O, sock buf sizes, TCP no-delay, etc.

  // For now, we just return success
  return 0;
}

// Determine the appropriate default thread flags, based on system.
// When I put the concurrency strategy into the factory, then this
// will go away b/c the concurrency strategy will do this appropriate
// for each platform!
#  if defined(linux)
#    define ROA_DEFAULT_THREADFLAGS  (THR_DETACHED)
#  elif defined(WIN32)
#    define ROA_DEFAULT_THREADFLAGS  (THR_DETACHED)
#  elif defined(sparc)
#    define ROA_DEFAULT_THREADFLAGS  (THR_DETACHED|THR_SCOPE_PROCESS)
#  else
#    define ROA_DEFAULT_THREADFLAGS  (THR_DETACHED)
#  endif

TAO_Server_Factory::CONCURRENCY_STRATEGY*
TAO_Server_Factory::concurrency_strategy ()
{
  TAO_OA_Parameters* p = TAO_OA_PARAMS::instance ();


  if (p->using_threads ())
    {
      // Set the strategy parameters
      threaded_strategy_.open (ACE_Service_Config::thr_mgr (),
			       ROA_DEFAULT_THREADFLAGS);
      concurrency_strategy_ = &threaded_strategy_;
    }
  else
    {
      reactive_strategy_.open (ACE_Service_Config::reactor ());
      concurrency_strategy_ = &reactive_strategy_;
    }

  return concurrency_strategy_;
}

TAO_Object_Table*
TAO_Server_Factory::object_lookup_strategy (void)
{
  TAO_OA_Parameters* p = TAO_OA_PARAMS::instance ();

  // Since these are dynamically created, when do they get destroyed?
  switch (p->demux_strategy ())
    {
    case TAO_OA_Parameters::TAO_LINEAR:
      this->objtable_ = new TAO_Linear_ObjTable (p->tablesize ());
      break;
    case TAO_OA_Parameters::TAO_USER_DEFINED:
      // it is assumed that the user would have used the hooks to supply a
      // user-defined instance of the object table
      ACE_ASSERT (this->objtable_ != 0);
      break;
    case TAO_OA_Parameters::TAO_ACTIVE_DEMUX:
      break;
    case TAO_OA_Parameters::TAO_DYNAMIC_HASH:
    default:
      this->objtable_ = new TAO_Dynamic_Hash_ObjTable (p->tablesize ());
    }
  return this->objtable_;
}

TAO_Client_Factory::TAO_Client_Factory (void)
{
  // When should I do this open ()?  It seems like this is way too
  // early, but doing it in the accessor for connector () seems like
  // it would be too late as well.
  connector_.open (ACE_Service_Config::reactor (),
		   &null_creation_strategy_,
		   &caching_connect_strategy_,
#if defined (TAO_HAS_CLIENT_CONCURRENCY)
		   concurrency_strategy_ ()
#else
		   0
#endif /* TAO_HAS_CLIENT_CONCURRENCY */
		   );
}

TAO_Client_Factory::~TAO_Client_Factory (void)
{}

#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION)
template class ACE_Thread_Strategy<TAO_OA_Connection_Handler>;
template class ACE_Concurrency_Strategy<TAO_OA_Connection_Handler>;
template class ACE_Reactive_Strategy<TAO_OA_Connection_Handler>;
template class ACE_Creation_Strategy<TAO_OA_Connection_Handler>;
template class ACE_Scheduling_Strategy<TAO_OA_Connection_Handler>;
template class ACE_Accept_Strategy<TAO_OA_Connection_Handler, ACE_SOCK_ACCEPTOR>;

template class ACE_Creation_Strategy<TAO_Client_Connection_Handler>;
template class ACE_Connect_Strategy<TAO_Client_Connection_Handler, ACE_SOCK_CONNECTOR>;
template class ACE_Concurrency_Strategy<TAO_Client_Connection_Handler>;
template class ACE_Cached_Connect_Strategy<TAO_Client_Connection_Handler, ACE_SOCK_CONNECTOR, ACE_RW_Thread_Mutex>;
template class ACE_NOOP_Creation_Strategy<TAO_Client_Connection_Handler>;
template class ACE_Strategy_Connector<TAO_Client_Connection_Handler, ACE_SOCK_CONNECTOR>;
template class ACE_Connector<TAO_Client_Connection_Handler, ACE_SOCK_CONNECTOR>;
#define TAO_HASH_ADDR ACE_Hash_Addr<ACE_INET_Addr, TAO_Client_Connection_Handler>
template class TAO_HASH_ADDR;
template class ACE_Hash_Map_Manager<TAO_HASH_ADDR, TAO_Client_Connection_Handler*, ACE_RW_Thread_Mutex>;
template class ACE_Hash_Map_Entry<TAO_HASH_ADDR, TAO_Client_Connection_Handler*>;
#define TAO_SVC_TUPLE ACE_Svc_Tuple<TAO_Client_Connection_Handler>
template class TAO_SVC_TUPLE;
template class ACE_Map_Manager<int, TAO_SVC_TUPLE*, ACE_RW_Thread_Mutex>;
template class ACE_Map_Iterator<int, TAO_SVC_TUPLE*, ACE_RW_Thread_Mutex>;
template class ACE_Map_Entry<int, TAO_SVC_TUPLE*>;

#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */