summaryrefslogtreecommitdiff
path: root/TAO/CIAO/tools/Config_Handlers/RT-CCM/TPL_Handler.cpp
blob: 5232b48a757d9041b3574657b76ee283bbf3fde3 (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
// $Id$

#include "TPL_Handler.h"
#include "CIAOServerResources.hpp"

namespace CIAO
{
  namespace Config_Handlers
  {
    bool 
    TPL_Handler::threadpool_with_lanes (
           const ThreadpoolWithLanesDef &src,
           ::CIAO::DAnCE::ORS_ThreadpoolWithLanes &dest)
    {
      if (src.id_p ())
        {
          dest.Id = CORBA::string_dup (src.id().c_str ());
        }

      for (ThreadpoolWithLanesDef::threadpoolLane_const_iterator loc =
             src.begin_threadpoolLane ();
           loc != src.end_threadpoolLane ();
           loc++)
        {
          size_t len = dest.threadpool_lanes.length ();

          dest.threadpool_lanes.length (len + 1);
                      
          dest.threadpool_lanes[len].lane_priority =
            static_cast <ACE_INT16> (loc->priority ());

          dest.threadpool_lanes[len].static_threads =
            static_cast <ACE_UINT32> (loc->static_threads ());

          dest.threadpool_lanes[len].dynamic_threads =
            static_cast <ACE_UINT32> (loc->dynamic_threads ());
        }

      dest.stacksize = static_cast <ACE_INT16> (src.stacksize ());

      dest.allow_borrowing = src.allow_borrowing ();

      dest.allow_request_buffering = src.allow_request_buffering ();

      dest.max_buffered_requests =
        static_cast <ACE_UINT32> (src.max_buffered_requests ());

      dest.max_request_buffer_size =
        static_cast <ACE_UINT32> (src.max_request_buffered_size ());
        
      return true;
    }

    ThreadpoolWithLanesDef TPL_Handler::threadpool_with_lanes (
           const ::CIAO::DAnCE::ORS_ThreadpoolWithLanes &src)
    {
      ThreadpoolWithLanesDef tpl (XMLSchema::unsignedLong (src.stacksize),
                                  XMLSchema::boolean ((src.allow_borrowing)),
                                  XMLSchema::boolean ((src.allow_request_buffering)),
                                  XMLSchema::unsignedLong ((src.max_buffered_requests)),
                                  XMLSchema::unsignedLong ((src.max_request_buffer_size))
                                  );
        
      //XMLSchema::ID <ACE_TCHAR> id = ((src.Id));
      tpl.id (src.Id.in ());
        
      size_t len = src.threadpool_lanes.length ();
      for (size_t i = 0; i < len; i++)
        {
          ThreadpoolLaneDef new_tplane (
               XMLSchema::unsignedLong (src.threadpool_lanes[i].static_threads),
               XMLSchema::unsignedLong (src.threadpool_lanes[i].dynamic_threads),
               XMLSchema::int_ (src.threadpool_lanes[i].lane_priority));
                          
          tpl.add_threadpoolLane (new_tplane);
        } 
              
      return tpl;
    }
  }
}