summaryrefslogtreecommitdiff
path: root/TAO/examples/Event_Comm/notifier.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/examples/Event_Comm/notifier.cpp')
-rw-r--r--TAO/examples/Event_Comm/notifier.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/TAO/examples/Event_Comm/notifier.cpp b/TAO/examples/Event_Comm/notifier.cpp
new file mode 100644
index 00000000000..774eea4db30
--- /dev/null
+++ b/TAO/examples/Event_Comm/notifier.cpp
@@ -0,0 +1,68 @@
+// $Id$
+
+#include "Notifier_Server.h"
+#include "notifier.h"
+ACE_RCSID(Notifier, notifier, "$Id$")
+
+
+int
+Notifier::handle_signal (int signum, siginfo_t *, ucontext_t *)
+{
+ ACE_DEBUG ((LM_DEBUG,
+ "got signal in handle_signal %S\n",
+ signum));
+
+ // Tell the <Notifier_Server> to shut down the ORB.
+ ns_.close ();
+ return 0;
+}
+
+void
+Notifier::run (void)
+{
+ try
+ {
+ ns_.run ();
+ }
+ catch (const CORBA::Exception&)
+ {
+ return;
+ }
+}
+
+Notifier::Notifier (int argc, char *argv[])
+{
+ try
+ {
+ ns_.init (argc, argv);
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("Notifier_Server.init failed\n ");
+ }
+
+ // Register with the ORB's Reactor to receive a signal to shut us
+ // down.
+ if (ns_.reactor ()->register_handler (SIGINT, this) == -1)
+ ACE_ERROR ((LM_ERROR,
+ "%p\n",
+ "register_handler"));
+}
+
+Notifier::~Notifier (void)
+{
+ // Cleanup.
+ this->ns_.close ();
+}
+
+int
+main (int argc, char *argv[])
+{
+ // Initialize server daemon.
+ Notifier notifier (argc, argv);
+
+ // Loop forever handling events.
+ notifier.run ();
+
+ return 0;
+}