3 #include "tao/ORB_Core.h"
4 #include "tao/LF_Strategy.h"
5 #include "ace/Reactor.h"
7 #if !defined(__ACE_INLINE__)
9 #endif /* __ACE_INLINE__ */
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"));
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 ()));
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");
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 ();
57 Simple_Server_i::handle_timeout (const ACE_Time_Value
&,
60 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX
, ace_mon
, this->lock_
, 0);
61 // We are the (client) leader. Signal the leader-follower pattern to
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"));
73 Simple_Server_i::shutdown ()
75 this->orb_
->shutdown (false);