1 #include "AppShutdown.h"
2 #include "TestAppExceptionC.h"
3 #include "ace/Log_Msg.h"
4 #include "ace/OS_NS_unistd.h"
7 AppShutdown::AppShutdown()
9 num_clients_shutdown_(0)
14 AppShutdown::~AppShutdown()
20 AppShutdown::init(CORBA::ORB_ptr orb
,
23 if ((!CORBA::is_nil(this->orb_
.in())) ||
24 (CORBA::is_nil(orb
)) ||
27 // Already init()'ed, or bad argument values.
28 throw TestAppException();
32 this->orb_
= CORBA::ORB::_duplicate(orb
);
33 this->num_clients_
= num_clients
;
34 this->num_clients_shutdown_
= 0;
42 this->orb_shutdown_task_
.wait();
47 AppShutdown::client_done()
49 if ((this->num_clients_
== 0) || (CORBA::is_nil(this->orb_
.in())))
51 ACE_ERROR((LM_ERROR
, "(%P|%t) AppShutdown was never initialized.\n"));
55 unsigned cur_shutdown
= ++this->num_clients_shutdown_
;
57 if (cur_shutdown
== this->num_clients_
)
59 // Sleep for one second before shutting down the ORB. This
60 // is a poor-man version of "wait until the CSD request queue drains".
62 this->orb_shutdown_task_
.orb(this->orb_
.in());
63 if (this->orb_shutdown_task_
.open(0) != 0)
65 ACE_ERROR((LM_ERROR
, "(%P|%t) AppShutdown failed to create orb "\
66 "shutdown thread.\n"));
74 AppShutdown::instance ()
76 static AppShutdown app_shutdown
;