Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / orbsvcs / tests / CosEvent / Timeout / TestEventConsumer_i.cpp
blob1995a03bc093038656a09e46dc90f10de8eba416
1 #include "TestEventConsumer_i.h"
3 #include "ace/Log_Msg.h"
5 TestEventConsumer_i::TestEventConsumer_i (CORBA::ORB_ptr orb, bool hang)
6 : orb_ (CORBA::ORB::_duplicate (orb)),
7 hang_ (hang),
8 count_ (0),
9 orbtask_ (orb),
10 cond_ (this->mtx_),
11 shutdown_ (false)
15 void
16 TestEventConsumer_i::activate ()
18 this->orbtask_.activate ();
21 int
22 TestEventConsumer_i::ORB_task::svc ()
24 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("TestEventConsumer_i ORB_task starting\n")));
25 try
27 this->orb_->run ();
28 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("TestEventConsumer_i ORB_task exiting\n")));
30 catch (const CORBA::SystemException &e)
32 e._tao_print_exception (
33 ACE_TEXT (
34 "TestEventConsumer_i ORB_task: Caught CORBA::Exception:"));
36 return 0;
39 void
40 TestEventConsumer_i::push (const CORBA::Any & data)
42 // Extract event data from the any.
43 const char *eventData;
44 if (data >>= eventData)
46 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("TestEventConsumer_i::push(): Received ")
47 ACE_TEXT ("event containing %d bytes.\n"),
48 ACE_OS::strlen (eventData)));
49 if (this->hang_ && ++this->count_ == 10)
51 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("TestEventConsumer_i::push(): ")
52 ACE_TEXT ("Simulating hung consumer\n")));
54 ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->mtx_);
55 while (!this->shutdown_)
56 this->cond_.wait ();
58 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("TestEventConsumer_i::push Done\n")
59 ));
64 void
65 TestEventConsumer_i::disconnect_push_consumer ()
67 ACE_DEBUG ((LM_DEBUG,
68 ACE_TEXT ("TestEventConsumer_i::disconnect_push_consumer()\n")));
69 this->orb_->shutdown ();
70 this->shutdown_ = true;
71 this->cond_.signal ();