3 #include "ace/OS_NS_unistd.h"
7 class ORB_Task
: public ACE_Task_Base
10 ORB_Task (CORBA::ORB_ptr orb
)
11 : orb_ (CORBA::ORB::_duplicate (orb
))
15 virtual int svc (void)
19 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) Event loop started\n"));
21 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) Event loop finished\n"));
23 catch (const CORBA::Exception
& )
33 class Worker_Task
: public ACE_Task_Base
36 Worker_Task (CORBA::ORB_ptr orb
)
37 : orb_ (CORBA::ORB::_duplicate (orb
))
41 virtual int svc (void)
45 Message_init
*mi
= new Message_init ();
46 CORBA::ValueFactoryBase_var
safe (mi
);
50 CORBA::ValueFactoryBase_var tmp1
=
51 this->orb_
->register_value_factory (mi
->tao_repository_id (), mi
);
53 CORBA::ValueFactoryBase_var tmp2
=
54 this->orb_
->lookup_value_factory (mi
->tao_repository_id ());
56 this->orb_
->unregister_value_factory (mi
->tao_repository_id ());
59 catch (const CORBA::BAD_INV_ORDER
&)
61 // It's ok to ignore BAD_INV_ORDER which can be thrown after orb
62 // is shutdown from other thread.
64 catch (const CORBA::Exception
&)
67 ACE_TEXT ("ERROR: Unexpected exception.\n")));
78 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
82 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
84 ORB_Task
orb_runner (orb
.in ());
85 if (orb_runner
.activate (THR_NEW_LWP
| THR_JOINABLE
, 1) == -1)
87 ACE_ERROR_RETURN ((LM_ERROR
,
88 "ERROR: Can not start ORB thread\n"),
94 Worker_Task
work_runner (orb
.in ());
95 if (work_runner
.activate (THR_NEW_LWP
| THR_JOINABLE
, 10) == -1)
97 ACE_ERROR_RETURN ((LM_ERROR
,
98 "ERROR: Can not start work threads\n"),
104 ACE_DEBUG ((LM_DEBUG
,
105 ACE_TEXT ("(%P|%t) Shutting down / destroying ORB\n")));
107 orb
->shutdown (false);
109 ACE_Thread_Manager::instance ()->wait ();
113 catch (const CORBA::Exception
& ex
)
115 ex
._tao_print_exception ("Exception caught:");