Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / Bug_3531_Regression / test_i.cpp
blob7e05d4d9de14fb448219b6ef4f45b0ccf1722dc7
1 #include "test_i.h"
2 #include "tao/debug.h"
3 #include "tao/ORB_Core.h"
4 #include "tao/LF_Strategy.h"
5 #include "ace/Reactor.h"
7 #if !defined(__ACE_INLINE__)
8 #include "test_i.inl"
9 #endif /* __ACE_INLINE__ */
11 char *
12 Simple_Server_i::test_method (Simple_Server_ptr objref)
14 ACE_DEBUG ((LM_DEBUG, "(%P|%t) test_method called\n"));
15 if (CORBA::is_nil (objref))
17 ACE_ERROR ((LM_ERROR, "Nil object reference!\n"));
19 else
21 try
24 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0);
25 if (!this->timer_registed_)
27 ACE_DEBUG ((LM_DEBUG, "(%P|%t) Scheduling timeout...\n"));
28 ACE_Time_Value timeout (2, 0);
29 ACE_Reactor * reactor = this->orb_->orb_core ()->reactor ();
30 reactor->schedule_timer (this, (void*)0, timeout);
31 this->timer_registed_ = true;
34 ACE_DEBUG ((LM_DEBUG, "(%P|%t) Calling test_method() on client, "
35 "which will sleep for 3 seconds\n"));
36 CORBA::String_var str = objref->test_method (_this());
37 ACE_DEBUG ((LM_DEBUG, "(%P|%t) Received \"%C\"\n", str.in ()));
39 catch (...)
41 ACE_ERROR ((LM_ERROR, "(%P|%t) Caught exception\n"));
44 ACE_DEBUG ((LM_DEBUG, "(%P|%t) leaving test_method\n"));
45 return CORBA::string_dup("Hello world");
48 void
49 Simple_Server_i::client_done ()
51 ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_);
52 ACE_DEBUG ((LM_DEBUG, "(%P|%t) Simple_Server_i::client_done () called\n"));
53 this->cond_.signal ();
56 int
57 Simple_Server_i::handle_timeout (const ACE_Time_Value &,
58 const void *)
60 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0);
61 // We are the (client) leader. Signal the leader-follower pattern to
62 // elect a new leader
63 TAO_ORB_Core *oc = orb_->orb_core();
64 oc->lf_strategy ().set_upcall_thread (oc->leader_follower ());
65 // Block until another thread is elected leader and handles a *new* event.
66 ACE_DEBUG ((LM_DEBUG, "(%P|%t) handle_timeout () called - waiting...\n"));
67 this->cond_.wait();
68 return 0;
72 void
73 Simple_Server_i::shutdown ()
75 this->orb_->shutdown (false);