summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/performance-tests/RTEvent/lib/RTCORBA_Setup.cpp
blob: b5c6d99ae377bf0767fbbea5a5707bcaeb737ce6 (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
/**
 * @file RTCORBA_Setup.cpp
 *
 * $Id$
 *
 * @author Carlos O'Ryan <coryan@uci.edu>
 */

#include "RTCORBA_Setup.h"
#include "RIR_Narrow.h"
#include "RT_Class.h"

#include "ace/Log_Msg.h"

#if !defined(__ACE_INLINE__)
#include "RTCORBA_Setup.inl"
#endif /* __ACE_INLINE__ */

ACE_RCSID (TAO_PERF_RTEC, 
           RTCORBA_Setup, 
           "$Id$")

RTCORBA_Setup::RTCORBA_Setup (CORBA::ORB_ptr orb,
                              const RT_Class &rtclass,
                              int nthreads
                              ACE_ENV_ARG_DECL)
  :  lanes_ (3)
{
  this->priority_mapping_manager_ =
    RIR_Narrow<RTCORBA::PriorityMappingManager>::resolve (orb,
                                                          "PriorityMappingManager"
                                                          ACE_ENV_ARG_PARAMETER);
  ACE_CHECK;

  this->priority_mapping_ =
    this->priority_mapping_manager_->mapping ();

  RTCORBA::Current_var current =
    RIR_Narrow<RTCORBA::Current>::resolve (orb,
                                           "RTCurrent"
                                           ACE_ENV_ARG_PARAMETER);
  ACE_CHECK;

  RTCORBA::Priority corba_prc_priority;
  this->priority_mapping_->to_CORBA (rtclass.priority_process (),
                                     corba_prc_priority);

  current->the_priority (corba_prc_priority
                         ACE_ENV_ARG_PARAMETER);
  ACE_CHECK;

  this->lanes_.length (3);

  this->setup_lane (rtclass.priority_high (),
                    this->lanes_[0]
                    ACE_ENV_ARG_PARAMETER);
  ACE_CHECK;
  this->setup_lane (rtclass.priority_process (),
                    this->lanes_[1]
                    ACE_ENV_ARG_PARAMETER);
  ACE_CHECK;
  this->setup_lane (rtclass.priority_low (),
                    this->lanes_[2]
                    ACE_ENV_ARG_PARAMETER);
  ACE_CHECK;
  this->lanes_[2].static_threads = nthreads;

  this->process_priority_ = this->lanes_[1].lane_priority;
}

void
RTCORBA_Setup::setup_lane (int priority,
                           RTCORBA::ThreadpoolLane &lane
			   ACE_ENV_ARG_DECL)
{
  if (!this->priority_mapping_->to_CORBA (priority,
                                          lane.lane_priority))
    ACE_THROW (CORBA::BAD_PARAM ());

  lane.static_threads  = 1;
  lane.dynamic_threads = 0;
}