summaryrefslogtreecommitdiff
path: root/TAO/tests/Oneways_Invoking_Twoways/Client_Task.cpp
blob: f82bb6483f50e7b7d6bafce4364a0176e59c01c6 (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
//
// $Id$
//

#include "Client_Task.h"
#include "ace/OS_NS_unistd.h"

ACE_RCSID(Muxing, Client_Task, "$Id$")

Client_Task::Client_Task (Test::Sender_ptr reply_gen,
                          Test::Receiver_ptr us,
                          ACE_Thread_Manager *thr_mgr,
                           Receiver_i * receiver_impl)
  : ACE_Task_Base (thr_mgr)
  , sender_(Test::Sender::_duplicate (reply_gen))
  , us_ (Test::Receiver::_duplicate (us))
  , receiver_impl_ (receiver_impl)

{
}

int
Client_Task::svc (void)
{
  ACE_DEBUG ((LM_DEBUG, "(%P|%t) Starting client task\n"));

  try
    {
      for (int i = 0; i != 1; ++i)
        {
          ACE_DEBUG ((LM_DEBUG,
                      "TAO (%P|%t) sending oneways...\n"));

          this->sender_->send_ready_message (this->us_.in ());
        }

      // sleeps are evil but 1 sec or so is an improvement on the minute plus
      // this poorly implemented test used to take
      while (this->receiver_impl_->no_calls_ < 10)
        ACE_OS::sleep (1);
      this->sender_->shutdown ();

      this->us_->shutdown ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Caught Exception");
      return -1;
    }
  ACE_DEBUG ((LM_DEBUG, "(%P|%t) Client task finished\n"));
  return 0;
}