summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/RTCosScheduling/Object1_i.cpp
blob: 92ea6cc74f630c4283ca62fd2f832bf1b2d427f3 (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
/* -*- C++ -*- */

//=============================================================================
/**
 *  @file    Object1_i.cpp
 *
 *  $Id$
 *
 *  @author Matt Murphy <murphym@cs.uri.edu>
 */
//=============================================================================

#include "Object1_i.h"
#include "ace/ACE.h"
#include "ace/OS_NS_stdio.h"
#include "ace/OS_NS_string.h"
#include "ace/OS_NS_unistd.h"
//#include "tao/RTCORBA/RTCORBA.h"
////##include "ace/Task.h"
//
//#if !defined (ACE_LACKS_PRAGMA_ONCE)
//# pragma once
//#endif /* ACE_LACKS_PRAGMA_ONCE */
//
////#include "ace/CORBA_macros.h"
////#include "tao/RTCORBA/Priority_Mapping_Manager.h"
////#include "tao/corba.h"
////#include "tao/ORB_Core.h"
//

Object1_impl::Object1_impl()
{
}


Object1_impl::~Object1_impl()
{
}


void Object1_impl::method1(const char* activity,
    CORBA::Long seconds,
    char* &output
    ACE_ENV_ARG_DECL_NOT_USED)
  ACE_THROW_SPEC ((CORBA::SystemException, testSched::testSchedException))
{
  const int scale_factor = 2000;
  int work;
  const int time_size = 35;
  ACE_TCHAR date_and_time[time_size];
  char buf[128];
  char buf2[128];

  ACE_OS::sprintf(buf,
                  "%s\t%s\tBeginning work on the server\n",
                   ACE::timestamp(date_and_time, time_size),
                   activity);
  ACE_DEBUG((LM_DEBUG,"%s",buf));

  if (ACE_OS::strcmp(activity,"Client1") == 0)
    {
       ACE_OS::sleep(5);
    }

  /// Simulate some work
  static CORBA::ULong prime_number = 9619;
  work = scale_factor * seconds;
  for (; work != 0; work--)
    {
      ACE::is_prime (prime_number, 2, prime_number / 2);
    }

  ACE_OS::sprintf(buf2,
                  "%s\t%s\tFinished work on the server\n",
                  ACE::timestamp(date_and_time, time_size),
                  activity);
  ACE_DEBUG((LM_DEBUG,"%s",buf2));
  ACE_OS::strcat(buf,buf2);
  output = ACE_OS::strdup(buf);

}