summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpradeep <pradeep@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-11-08 03:07:06 +0000
committerpradeep <pradeep@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-11-08 03:07:06 +0000
commitc07ed92978b91af75fbc406bf833ab79e78df90e (patch)
tree094fa2aa3b407cb5b018b19f6744c4850d558042
parente60d9a1cbe97a32e01879e3a9ec5414a90ff6714 (diff)
downloadATCD-c07ed92978b91af75fbc406bf833ab79e78df90e.tar.gz
*** empty log message ***
-rw-r--r--TAO/examples/Event_Comm/Consumer_Handler.cpp14
-rw-r--r--TAO/examples/Event_Comm/Consumer_Handler.h5
-rw-r--r--TAO/examples/Event_Comm/Event_Comm_i.cpp10
-rw-r--r--TAO/examples/Event_Comm/Event_Comm_i.h8
-rw-r--r--TAO/examples/Event_Comm/Notifier_Handler.cpp35
-rw-r--r--TAO/examples/Event_Comm/Notifier_Handler.h14
-rw-r--r--TAO/examples/Event_Comm/Supplier_Input_Handler.cpp18
-rw-r--r--TAO/examples/Event_Comm/consumer.cpp2
-rw-r--r--TAO/examples/Event_Comm/supplier.cpp22
9 files changed, 91 insertions, 37 deletions
diff --git a/TAO/examples/Event_Comm/Consumer_Handler.cpp b/TAO/examples/Event_Comm/Consumer_Handler.cpp
index c2b86f0eb20..46bd99e7433 100644
--- a/TAO/examples/Event_Comm/Consumer_Handler.cpp
+++ b/TAO/examples/Event_Comm/Consumer_Handler.cpp
@@ -7,7 +7,7 @@ ACE_RCSID(Consumer, Consumer_Handler, "$Id$")
Consumer_Handler::Consumer_Handler (void)
: receiver_ (0),
notifier_ (0),
- consumershutdown (0)
+ shutdowncallback (0)
{
// No-Op.
}
@@ -20,7 +20,7 @@ Consumer_Handler::~Consumer_Handler (void)
int
Consumer_Handler::init (int argc,
char *argv[],
- ConsumerShutdown *_consumershutdown)
+ ShutdownCallback *_shutdowncallback)
{
char *filtering_criteria = "";
@@ -42,10 +42,10 @@ Consumer_Handler::init (int argc,
TAO_CHECK_ENV;
// Save the Shutdown callback.
- this->consumershutdown = _consumershutdown;
- // Set the ConsumerShutdown callback object
+ this->shutdowncallback = _shutdowncallback;
+ // Set the ShutdownCallback callback object
// in the Consumer object implementation.
- this->receiver_i_.set (_consumershutdown);
+ this->receiver_i_.set (_shutdowncallback);
// Start the servant.
this->receiver_ =
@@ -121,9 +121,9 @@ Consumer_Handler::close (void)
void
Consumer_Handler::shutdown (void)
{
- ACE_ASSERT (this->consumershutdown != 0);
+ ACE_ASSERT (this->shutdowncallback != 0);
- this->consumershutdown->close ();
+ this->shutdowncallback->close ();
}
int
diff --git a/TAO/examples/Event_Comm/Consumer_Handler.h b/TAO/examples/Event_Comm/Consumer_Handler.h
index b345b9b1d86..69219365550 100644
--- a/TAO/examples/Event_Comm/Consumer_Handler.h
+++ b/TAO/examples/Event_Comm/Consumer_Handler.h
@@ -43,7 +43,7 @@ public:
virtual ~Consumer_Handler (void);
// Destructor.
- int init (int argc, char *argv[], ConsumerShutdown *consumershutdown);
+ int init (int argc, char *argv[], ShutdownCallback *_shutdowncallback);
// Initializes the ORB, gets the Notifier reference from the Naming
// Service, and starts the servant for the Consumer object.
@@ -61,6 +61,7 @@ public:
Event_Comm::Notifier *notifier (void);
ACE_Reactor *reactor (void);
+ // returns the ORB's reactor.
private:
int get_notifier (void);
@@ -83,7 +84,7 @@ private:
CORBA::ORB_var orb_;
// Remember our orb.
- ConsumerShutdown* consumershutdown;
+ ShutdownCallback* shutdowncallback;
// The Shutdown callback used to shutdown the consumer application.
};
diff --git a/TAO/examples/Event_Comm/Event_Comm_i.cpp b/TAO/examples/Event_Comm/Event_Comm_i.cpp
index 5c2cc8e288f..ed769eab67e 100644
--- a/TAO/examples/Event_Comm/Event_Comm_i.cpp
+++ b/TAO/examples/Event_Comm/Event_Comm_i.cpp
@@ -384,7 +384,7 @@ Notifier_i::push (const Event_Comm::Event &event,
}
Consumer_i::Consumer_i (void)
- : consumershutdown (0)
+ : shutdown (0)
{
}
@@ -417,15 +417,15 @@ Consumer_i::disconnect (const char *reason,
"**** got disconnected due to %s\n",
reason));
- ACE_ASSERT (consumershutdown != 0);
+ ACE_ASSERT (shutdown != 0);
- consumershutdown->close ();
+ shutdown->close ();
}
void
-Consumer_i::set (ConsumerShutdown *_consumershutdown)
+Consumer_i::set (ShutdownCallback *_shutdown)
{
- consumershutdown = _consumershutdown;
+ shutdown = _shutdown;
}
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
diff --git a/TAO/examples/Event_Comm/Event_Comm_i.h b/TAO/examples/Event_Comm/Event_Comm_i.h
index 7eb3212ccf8..2a6347d976e 100644
--- a/TAO/examples/Event_Comm/Event_Comm_i.h
+++ b/TAO/examples/Event_Comm/Event_Comm_i.h
@@ -32,10 +32,10 @@
#include "ace/SString.h"
#include "Event_CommS.h"
-class ConsumerShutdown
+class ShutdownCallback
{
// = TITLE
- // Helper callback class to shutdown the Consumer application.
+ // Helper callback class to shutdown the application.
public:
virtual void close (void) = 0;
};
@@ -64,11 +64,11 @@ public:
// Disconnect the <Consumer> from the <Notifier>, giving it the
// <reason>.
- void set (ConsumerShutdown *_consumershutdown);
+ void set (ShutdownCallback *_shutdown);
// Set the Shutdown callback.
private:
- ConsumerShutdown *consumershutdown;
+ ShutdownCallback *shutdown;
// The callback to shutdown the consumer application.
};
diff --git a/TAO/examples/Event_Comm/Notifier_Handler.cpp b/TAO/examples/Event_Comm/Notifier_Handler.cpp
index 0c8683b1bee..2aab13fcb91 100644
--- a/TAO/examples/Event_Comm/Notifier_Handler.cpp
+++ b/TAO/examples/Event_Comm/Notifier_Handler.cpp
@@ -13,7 +13,7 @@ Notifier_Handler::Notifier_Handler (void)
Notifier_Handler::~Notifier_Handler (void)
{
- this->close ();
+ // No-Op.
}
int
@@ -27,9 +27,35 @@ Notifier_Handler::close (void)
this->notifier_ = 0;
}
+ // shutdown the ORB.
+ this->orb_->shutdown ();
return 0;
}
+void
+Notifier_Handler::shutdown (void)
+{
+ ACE_ASSERT (this->shutdowncallback != 0);
+
+ this->shutdowncallback->close ();
+}
+
+int
+Notifier_Handler::run (void)
+{
+ // Run the ORB.
+ this->orb_->run ();
+ return 0;
+}
+
+ACE_Reactor*
+Notifier_Handler::reactor(void)
+{
+ // @@ Please see if there's a way to get to the Reactor without
+ // using the TAO_ORB_Core_instance().
+ return TAO_ORB_Core_instance ()->reactor ();
+}
+
Event_Comm::Notifier *
Notifier_Handler::notifier (void)
{
@@ -49,8 +75,13 @@ Notifier_Handler::notifier (Event_Comm::Notifier *notifier)
// Init function.
int
-Notifier_Handler::init (int argc, char *argv[])
+Notifier_Handler::init (int argc,
+ char *argv[],
+ ShutdownCallback* _shutdowncallback)
{
+ // set the callback
+ shutdowncallback = _shutdowncallback;
+
TAO_TRY
{
// Retrieve the ORB.
diff --git a/TAO/examples/Event_Comm/Notifier_Handler.h b/TAO/examples/Event_Comm/Notifier_Handler.h
index a3915c30562..cf83f94de6f 100644
--- a/TAO/examples/Event_Comm/Notifier_Handler.h
+++ b/TAO/examples/Event_Comm/Notifier_Handler.h
@@ -42,16 +42,25 @@ public:
virtual ~Notifier_Handler (void);
// Destructor.
- int init (int argc, char *argv[]);
+ int init (int argc, char *argv[], ShutdownCallback* _shutdowncallback);
// Initialize the client communication endpoint with server.
// = Accessors.
Event_Comm::Notifier *notifier (void);
void notifier (Event_Comm::Notifier *);
+ int run (void);
+ // runs the ORB.
+
int close (void);
// Close down the handler.
+ void shutdown (void);
+ // called to request application shutdown.
+
+ ACE_Reactor *reactor (void);
+ // returns the ORB's reactor.
+
private:
Event_Comm::Notifier *notifier_;
// Pointer to an <Event_Comm::Notifier> object.
@@ -62,6 +71,9 @@ private:
CORBA::ORB_var orb_;
// Remember our orb.
+
+ ShutdownCallback *shutdowncallback;
+ // The handler to shutdown the app.
};
#define NOTIFIER_BIND_NAME "Notifier"
diff --git a/TAO/examples/Event_Comm/Supplier_Input_Handler.cpp b/TAO/examples/Event_Comm/Supplier_Input_Handler.cpp
index 27d3c4b9a72..45210031b4b 100644
--- a/TAO/examples/Event_Comm/Supplier_Input_Handler.cpp
+++ b/TAO/examples/Event_Comm/Supplier_Input_Handler.cpp
@@ -16,7 +16,6 @@ Supplier_Input_Handler::~Supplier_Input_Handler (void)
{
ACE_DEBUG ((LM_DEBUG,
"closing down Supplier_Input_Handler::~Supplier_Input_Handler\n"));
- this->close ();
}
int
@@ -28,7 +27,7 @@ Supplier_Input_Handler::close (void)
// Make sure to cleanup the STDIN handler.
if (ACE_Event_Handler::remove_stdin_handler
(
- ACE_Reactor::instance (),
+ TAO_ORB_Core_instance ()->reactor (),
TAO_ORB_Core_instance ()->thr_mgr ()) == -1)
ACE_ERROR ((LM_ERROR,
"%p\n",
@@ -45,7 +44,7 @@ Supplier_Input_Handler::initialize (Notifier_Handler *notifier)
if (ACE_Event_Handler::register_stdin_handler
(this,
- ACE_Reactor::instance (),
+ TAO_ORB_Core_instance ()->reactor (),
TAO_ORB_Core_instance ()->thr_mgr ()) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"%p\n",
@@ -68,11 +67,10 @@ Supplier_Input_Handler::handle_input (ACE_HANDLE h)
if (ACE_OS::fgets (buf,
sizeof buf - 1,
stdin) == 0)
- {
- ACE_OS::strcpy (buf,
- "quit");
+ {
ACE_DEBUG ((LM_DEBUG,
"shutting down Supplier_Input_Handler\n"));
+ return 0;
}
else
{
@@ -88,14 +86,16 @@ Supplier_Input_Handler::handle_input (ACE_HANDLE h)
buf));
}
- Event_Comm::Notifier *notifier = this->notifier_->notifier ();
- ACE_ASSERT (notifier != 0);
+
if (ACE_OS::strncmp (buf, "quit", 4) == 0)
// Tell the main event loop to shutdown.
- ACE_Reactor::end_event_loop ();
+ this->notifier_->shutdown ();
else
{
+ Event_Comm::Notifier *notifier = this->notifier_->notifier ();
+ ACE_ASSERT (notifier != 0);
+
// Use the notifier to notify Consumers.
TAO_TRY
{
diff --git a/TAO/examples/Event_Comm/consumer.cpp b/TAO/examples/Event_Comm/consumer.cpp
index fcbb5392952..55b157feaf0 100644
--- a/TAO/examples/Event_Comm/consumer.cpp
+++ b/TAO/examples/Event_Comm/consumer.cpp
@@ -5,7 +5,7 @@
ACE_RCSID(Consumer, consumer, "$Id$")
-class Consumer : public ACE_Event_Handler, public ConsumerShutdown
+class Consumer : public ACE_Event_Handler, public ShutdownCallback
{
// = TITLE
// Consumer driver for the Publish/Subscribe example.
diff --git a/TAO/examples/Event_Comm/supplier.cpp b/TAO/examples/Event_Comm/supplier.cpp
index 9831b24380e..ebbe8a9ec46 100644
--- a/TAO/examples/Event_Comm/supplier.cpp
+++ b/TAO/examples/Event_Comm/supplier.cpp
@@ -5,7 +5,7 @@
ACE_RCSID(Supplier, supplier, "$Id$")
-class Supplier : public ACE_Event_Handler
+class Supplier : public ACE_Event_Handler, public ShutdownCallback
{
// = TITLE
// Supplier driver for the TAO Publish/Subscribe example.
@@ -27,6 +27,9 @@ public:
void run (void);
// Execute the supplier.
+ virtual void close (void);
+ // Shutdown the application.
+
private:
virtual int handle_signal (int signum,
siginfo_t *,
@@ -57,23 +60,30 @@ Supplier::handle_signal (int signum, siginfo_t *, ucontext_t *)
"%S\n",
signum));
- ACE_Reactor::end_event_loop ();
+ this->close ();
return 0;
}
void
Supplier::run (void)
{
- if (ACE_Reactor::run_event_loop () == -1)
+ if (nh_.run () == -1)
ACE_ERROR ((LM_ERROR,
"%p\n",
- "run_reactor_event_loop"));
+ "Notifier_Handler::run"));
+}
+
+void
+Supplier::close (void)
+{
+ ih_.close ();
+ nh_.close ();
}
int
Supplier::init (int argc, char *argv[])
{
- if (this->nh_.init (argc, argv) == -1)
+ if (this->nh_.init (argc, argv, this) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"%p\n",
"Notifier_Handler did not init\n"),
@@ -83,7 +93,7 @@ Supplier::init (int argc, char *argv[])
"%p\n",
"Supplier Input handler did not init\n"),
-1);
- else if (ACE_Reactor::instance ()->register_handler (SIGINT,
+ else if (nh_.reactor ()->register_handler (SIGINT,
this) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"%p\n",