diff options
author | pradeep <pradeep@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-11-07 21:01:38 +0000 |
---|---|---|
committer | pradeep <pradeep@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-11-07 21:01:38 +0000 |
commit | 33b97ba1ce6dde3c7125e9b9394292ff4864a0f0 (patch) | |
tree | 049aa231dfa119e02fdbdf5800755d4e3d65110c /TAO | |
parent | 0419e41c731f77200e8333518a767fc084ecc7bd (diff) | |
download | ATCD-33b97ba1ce6dde3c7125e9b9394292ff4864a0f0.tar.gz |
*** empty log message ***
Diffstat (limited to 'TAO')
-rw-r--r-- | TAO/examples/Event_Comm/Consumer_Handler.cpp | 7 | ||||
-rw-r--r-- | TAO/examples/Event_Comm/Consumer_Handler.h | 2 | ||||
-rw-r--r-- | TAO/examples/Event_Comm/Event_Comm_i.cpp | 31 | ||||
-rw-r--r-- | TAO/examples/Event_Comm/Event_Comm_i.h | 14 | ||||
-rw-r--r-- | TAO/examples/Event_Comm/consumer.cpp | 19 |
5 files changed, 52 insertions, 21 deletions
diff --git a/TAO/examples/Event_Comm/Consumer_Handler.cpp b/TAO/examples/Event_Comm/Consumer_Handler.cpp index 70ddac094b4..0e1885dd7be 100644 --- a/TAO/examples/Event_Comm/Consumer_Handler.cpp +++ b/TAO/examples/Event_Comm/Consumer_Handler.cpp @@ -17,7 +17,9 @@ Consumer_Handler::~Consumer_Handler (void) } int -Consumer_Handler::init (int argc, char *argv[]) +Consumer_Handler::init (int argc, + char *argv[], + ConsumerShutdown *consumershutdown) { char *filtering_criteria = ""; @@ -38,6 +40,9 @@ Consumer_Handler::init (int argc, char *argv[]) TAO_TRY_ENV); TAO_CHECK_ENV; + // set the ConsumerShutdown callback object. + this->receiver_i_.set (consumershutdown); + // Start the servant. this->receiver_ = this->receiver_i_._this (TAO_TRY_ENV); diff --git a/TAO/examples/Event_Comm/Consumer_Handler.h b/TAO/examples/Event_Comm/Consumer_Handler.h index 0bed428eb27..b2b61cfde69 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[]); + int init (int argc, char *argv[], ConsumerShutdown *consumershutdown); // Initializes the ORB, gets the Notifier reference from the Naming // Service, and starts the servant for the Consumer object. diff --git a/TAO/examples/Event_Comm/Event_Comm_i.cpp b/TAO/examples/Event_Comm/Event_Comm_i.cpp index 7aacd5f0c28..03992d8b20e 100644 --- a/TAO/examples/Event_Comm/Event_Comm_i.cpp +++ b/TAO/examples/Event_Comm/Event_Comm_i.cpp @@ -102,11 +102,11 @@ Consumer_Entry::Consumer_Entry (Event_Comm::Consumer *consumer, ACE_OS::strdup ("")); else { - #if defined (ACE_HAS_REGEX) + #if defined (ACE_HAS_REGEX) // Compile the regular expression (the 0's cause ACE_OS::compile // to allocate space). compile_buffer = ACE_OS::compile (filtering_criteria, 0, 0); - #else + #else // Win32 does not support regular expression functions such as compile. ACE_ALLOCATOR (compile_buffer, ACE_OS::strdup ("")); @@ -135,10 +135,10 @@ Consumer_Entry::~Consumer_Entry (void) Notifier_i::Notifier_i (size_t size) : map_ (size) { -// if platforms (such as win32) do not support the REGEXP functions +// if platforms (such as win32) do not support the REGEXP functions // such as <compile> and <step> then warn the user that the regular // expression feature is not available. - #ifndef ACE_HAS_REGEX + #ifndef ACE_HAS_REGEX ACE_DEBUG ((LM_DEBUG, "\n WARNING: This platform does not support the functions\ for regular expressions.\n\ The filtering criteria will not work.\n")); @@ -344,13 +344,13 @@ Notifier_i::push (const Event_Comm::Event &event, const char *criteria = me->int_id_->criteria (); ACE_ASSERT (criteria); - #if defined (ACE_HAS_REGEX) + #if defined (ACE_HAS_REGEX) // Do a regular expression comparison to determine matching. if (ACE_OS::strcmp ("", criteria) == 0 // Everything matches the wildcard. || ACE_OS::step (event.tag_, regexp) != 0) - #endif // #if defined (ACE_HAS_REGEX) - // if ACE_HAS_REGEX has not been defined, - // let everything through. + #endif // #if defined (ACE_HAS_REGEX) + // if ACE_HAS_REGEX has not been defined, + // let everything through. { ACE_DEBUG ((LM_DEBUG, "string %s matched regexp \"%s\" for client %x\n", @@ -383,6 +383,7 @@ Notifier_i::push (const Event_Comm::Event &event, } Consumer_i::Consumer_i (void) + : consumershutdown (0) { } @@ -415,13 +416,15 @@ Consumer_i::disconnect (const char *reason, "**** got disconnected due to %s\n", reason)); - // @@ Pradeep, can you please revise this so that rather than using - // TAO_ORB_Core_instance() you instead keep a pointer to your ORB - // instance and do the shutdown that way? The current approach - // won't be valid shortly when we add some new features to TAO. + ACE_ASSERT (consumershutdown != 0); + + consumershutdown->close (); +} - // Shutdown the orb. - TAO_ORB_Core_instance ()->orb ()->shutdown (); +void +Consumer_i::set (ConsumerShutdown *_consumershutdown) +{ + consumershutdown = _consumershutdown; } #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 afe0f892675..94d18e12816 100644 --- a/TAO/examples/Event_Comm/Event_Comm_i.h +++ b/TAO/examples/Event_Comm/Event_Comm_i.h @@ -32,6 +32,14 @@ #include "ace/SString.h" #include "Event_CommS.h" +class ConsumerShutdown +{ + // = TITLE + // Helper callback class to shutdown the Consumer application. +public: + virtual void close (void) = 0; +}; + class Consumer_i : public POA_Event_Comm::Consumer { // = TITLE @@ -55,6 +63,12 @@ public: CORBA::Environment &TAO_TRY_ENV); // Disconnect the <Consumer> from the <Notifier>, giving it the // <reason>. + + void set (ConsumerShutdown *_consumershutdown); + // Set the Shutdown callback. + +private: +ConsumerShutdown *consumershutdown; }; // Forward reference. diff --git a/TAO/examples/Event_Comm/consumer.cpp b/TAO/examples/Event_Comm/consumer.cpp index b0b9906c2cf..f68bec38361 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 +class Consumer : public ACE_Event_Handler, public ConsumerShutdown { // = TITLE // Consumer driver for the Publish/Subscribe example. @@ -27,6 +27,9 @@ public: int run (void); // Execute the consumer; + virtual void close (void); + // shutdown the consumer. + private: virtual int handle_signal (int signum, siginfo_t *, ucontext_t *); // Signal handler method. @@ -60,13 +63,19 @@ Consumer::handle_signal (int signum, // Indicate that the consumer initiated the shutdown. this->ih_.consumer_initiated_shutdown (1); - // Shut down the ORB - ih_.close (); - ch_.close (); + this->close (); return 0; } +void +Consumer::close (void) +{ + // Shut down the ORB + ih_.close (); + ch_.close (); +} + int Consumer::run (void) { @@ -78,7 +87,7 @@ int Consumer::initialize (int argc, char *argv[]) { // Initialize the <Consumer_Handler>. - if (this->ch_.init (argc, argv) == -1) + if (this->ch_.init (argc, argv, this) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "Consumer_Handler failed to initialize\n"), |