summaryrefslogtreecommitdiff
path: root/TAO/tao/Dynamic_TP/Dynamic_TP_POA_StrategyImpl.inl
blob: 8e62bc83a4933e3f5aaf4c015d034f193ab6e20c (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
123
124
125
126
127
128
// -*- C++ -*-
//
// $Id$

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

ACE_INLINE
TAO_Dynamic_TP_POA_StrategyImpl::TAO_Dynamic_TP_POA_StrategyImpl
(TAO_DTP_Definition * dynamic_tp_config,
 bool serialize_servants)
  : serialize_servants_(serialize_servants)
{
  //Need to govern the rules of the parameters coming in and set the
  //appropriate values.

  // Check to see if a null config got sent in.
  if (dynamic_tp_config != 0 )
    {
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("TAO (%P|%t) - Dynamic_TP_POA_StrategyImpl: ")
                  ACE_TEXT ("Initialized with:\n")
                  ACE_TEXT ("    initial_pool_threads_=[%d]\n")
                  ACE_TEXT ("    min_pool_threads_=[%d]\n")
                  ACE_TEXT ("    max_pool_threads_=[%d]\n")
                  ACE_TEXT ("    max_request_queue_depth_=[%d]\n")
                  ACE_TEXT ("    thread_stack_size_=[%d]\n")
                  ACE_TEXT ("    thread_idle_time_=[%d]\n"),
                  this->initial_pool_threads_,
                  this->min_pool_threads_,
                  this->max_pool_threads_,
                  this->max_request_queue_depth_,
                  this->thread_stack_size_,
                  this->thread_idle_time_.sec()));

      // initial_pool_threads_
      if (dynamic_tp_config->init_threads_ > 0)
        {
          this->initial_pool_threads_ = dynamic_tp_config->init_threads_;
        }
      else
        {
          this->initial_pool_threads_ = 5; // set to default
        }

      // min_pool_threads_

      if ( dynamic_tp_config->min_threads_ < this->initial_pool_threads_)
        {
          this->min_pool_threads_ = this->initial_pool_threads_;

        }
      else
        {
          this->min_pool_threads_ = dynamic_tp_config->min_threads_;
        }

      // max_pool_threads_

      if ( dynamic_tp_config->max_threads_ < this->min_pool_threads_)
        {
          this->max_pool_threads_ =  -1;   // Set to -1 so that max is unbounded.
        }
      else
        {
          this->max_pool_threads_ = dynamic_tp_config->max_threads_;
        }

      // thread_stack_size_

      if ( dynamic_tp_config->stack_size_ <= 0 )
        {
          this->thread_stack_size_ = ACE_DEFAULT_THREAD_STACKSIZE;
        }
      else
        {
          this->thread_stack_size_ = dynamic_tp_config->stack_size_;
        }

      // max_request_queue_depth_

      if ( dynamic_tp_config->queue_depth_ <= 0 )
        {
          this->max_request_queue_depth_ = -1;
        }
      else
        {
          this->max_request_queue_depth_ = dynamic_tp_config->queue_depth_;
        }

      // thread_idle_time_
      // TODO: Need functionality to trap for invalid ACE_Time_Value values

      this->thread_idle_time_ = dynamic_tp_config->timeout_;
    }
  else
    {
      // Configuration was sent in null, so leave constructor defaults in place
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("TAO (%P|%t) - Dynamic_TP_POA_StrategyImpl: ")
                  ACE_TEXT ("Null configuration provided, setting to defaults:\n")
                  ACE_TEXT ("     initial_pool_threads_=[%d]\n")
                  ACE_TEXT ("     min_pool_threads_=[%d]\n")
                  ACE_TEXT ("     max_pool_threads_=[%d]\n")
                  ACE_TEXT ("     max_request_queue_depth_=[%d]\n")
                  ACE_TEXT ("     thread_stack_size_=[%d]\n")
                  ACE_TEXT ("     thread_idle_time_=[%d]\n"),
                  this->initial_pool_threads_,
                  this->min_pool_threads_,
                  this->max_pool_threads_,
                  this->max_request_queue_depth_,
                  this->thread_stack_size_,
                  this->thread_idle_time_.sec ()));
    }


}


ACE_INLINE
void
TAO_Dynamic_TP_POA_StrategyImpl::set_servant_serialization(bool serialize_servants)
{
  // Simple Mutator.
  this->serialize_servants_ = serialize_servants;
}


TAO_END_VERSIONED_NAMESPACE_DECL