Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / DevGuideExamples / BiDirectionalGIOP / simple_i.cpp
blob32c5f1c39b4a5dc1852d8933e39a2172796ad64a
1 #include "bidir_giop_pch.h"
3 #include "simple_i.h"
5 #include "tao/ORB_Core.h"
6 #include "tao/Transport_Cache_Manager.h"
7 #include "tao/Thread_Lane_Resources.h"
9 #include <iostream>
11 Simple_i::Simple_i (CORBA::ORB_ptr orb, int callback_count)
12 : orb_(CORBA::ORB::_duplicate(orb))
13 , ready_for_callback_(0)
14 , callback_count_(callback_count)
15 , callback_(0)
19 Simple_i::~Simple_i (void)
23 CORBA::Long Simple_i::test_method (CORBA::Boolean do_callback)
25 if (do_callback) {
26 ready_for_callback_ = 1;
28 return 0;
31 void Simple_i::callback_object (Callback_ptr cb)
33 callback_ = Callback::_duplicate(cb);
36 void Simple_i::shutdown ()
38 CORBA::Boolean wait = false;
39 orb_->shutdown(wait);
42 int
43 Simple_i::call_client()
45 if (ready_for_callback_) {
47 ready_for_callback_ = 0;
49 for (int times = 0; times < callback_count_; ++times) {
51 callback_->callback_method();
53 if (orb_->orb_core()->lane_resources().transport_cache().current_size() > 1)
55 std::cerr << "The connection cache has grown. "
56 << "BiDirection did not work. aborting..." << std::endl;
57 ACE_OS::abort(); // Should probably define and throw a UserException
61 callback_->shutdown();
63 return 1;
66 return 0;