Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / AMI_Buffering / AMI_Buffering.cpp
blobcc3b457afe461ba0b5a6b57e6d1719e9db34bf7a
1 #include "AMI_Buffering.h"
3 AMI_Buffering::AMI_Buffering (CORBA::ORB_ptr orb,
4 Test::AMI_Buffering_Admin_ptr admin)
5 : orb_ (CORBA::ORB::_duplicate (orb)),
6 admin_ (Test::AMI_Buffering_Admin::_duplicate (admin)),
7 nest_ (0),
8 max_nest_ (0),
9 must_shutdown_ (false)
13 AMI_Buffering::Nest_Guard::Nest_Guard (AMI_Buffering &a)
14 :target_(a)
16 ++target_.nest_;
17 if (target_.nest_ > target_.max_nest_)
18 target_.max_nest_ = target_.nest_;
21 AMI_Buffering::Nest_Guard::~Nest_Guard ()
23 --target_.nest_;
26 void
27 AMI_Buffering::receive_data (const Test::Payload &the_payload)
29 try
31 AMI_Buffering::Nest_Guard ng(*this);
32 this->admin_->request_received (the_payload.length ());
34 catch (const CORBA::Exception&)
36 ACE_DEBUG ((LM_DEBUG,"(%P|%t) DEBUG: AMI_Buffering::receive_data"));
39 this->try_shutdown();
42 void
43 AMI_Buffering::flush ()
47 void
48 AMI_Buffering::sync ()
50 this->admin_->flush ();
53 void
54 AMI_Buffering::shutdown ()
56 this->must_shutdown_ = true;
57 this->try_shutdown();
60 void
61 AMI_Buffering::try_shutdown()
63 if (!this->must_shutdown_ || this->nest_ > 0)
64 return;
65 if (this->max_nest_ > 1)
66 ACE_DEBUG ((LM_DEBUG, "(%P|%t) max nesting level: %d\n", max_nest_));
67 this->admin_->shutdown();
69 this->orb_->shutdown (false);