summaryrefslogtreecommitdiff
path: root/tests/Big_Oneways/Peer.cpp
blob: b5bdeb94a7b470014788a2035dc0967ed1bed87a (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
//
// $Id$
//
#include "Peer.h"
#include "Session.h"

Peer::Peer (CORBA::ORB_ptr orb)
  : orb_ (CORBA::ORB::_duplicate (orb))
{
}

Peer::~Peer (void)
{
}

Test::Session_ptr
Peer::create_session (Test::Session_Control_ptr control,
                      CORBA::ULong payload_size,
                      CORBA::ULong thread_count,
                      CORBA::ULong message_count,
                      CORBA::ULong peer_count)
{
  Session *session_impl = 0;
  ACE_NEW_THROW_EX (session_impl,
                    Session (control,
                             payload_size,
                             thread_count,
                             message_count,
                             peer_count),
                    CORBA::NO_MEMORY ());
  PortableServer::ServantBase_var transfer_ownership (session_impl);
  Test::Session_var session;

#if defined (CORBA_E_COMPACT) || defined (CORBA_E_MICRO)
  PortableServer::POA_var poa = this->_default_POA ();
  PortableServer::ObjectId_var id = poa->activate_object (transfer_ownership.in ());
  CORBA::Object_var object = poa->id_to_reference (id.in ());
  session = Test::Session::_unchecked_narrow (object.in());
#else
  session = session_impl->_this ();
#endif /* CORBA_E_COMPACT || CORBA_E_MICRO */

  return session._retn ();
}

void
Peer::shutdown (void)
{
  ACE_DEBUG ((LM_DEBUG,
              "(%P|%t) Peer::shutdown, waiting for threads\n"));

  ACE_DEBUG ((LM_DEBUG,
              "(%P|%t) Peer::shutdown, shutting down ORB\n"));
  this->orb_->shutdown (0);
}