diff options
author | kirthika <kirthika@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-11-02 08:46:46 +0000 |
---|---|---|
committer | kirthika <kirthika@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-11-02 08:46:46 +0000 |
commit | fb26b2176f7be062cff42c8c69418b9c79942658 (patch) | |
tree | 6336f903a46e6c77082cf0fb3f7ddf46f9aa8639 | |
parent | f21fb98b72bf6ad3a6bff5cf11d2f3a37dc22478 (diff) | |
download | ATCD-fb26b2176f7be062cff42c8c69418b9c79942658.tar.gz |
*** empty log message ***
-rw-r--r-- | TAO/examples/Callback_Quoter/Consumer_Handler.cpp | 2 | ||||
-rw-r--r-- | TAO/examples/Callback_Quoter/Makefile | 17 | ||||
-rw-r--r-- | TAO/examples/Callback_Quoter/Notifier_i.cpp | 10 | ||||
-rw-r--r-- | TAO/examples/Callback_Quoter/Notifier_i.h | 2 | ||||
-rw-r--r-- | TAO/examples/Callback_Quoter/Supplier_i.cpp | 70 | ||||
-rw-r--r-- | TAO/examples/Callback_Quoter/Supplier_i.h | 31 |
6 files changed, 108 insertions, 24 deletions
diff --git a/TAO/examples/Callback_Quoter/Consumer_Handler.cpp b/TAO/examples/Callback_Quoter/Consumer_Handler.cpp index 53836c7d744..5018ffc709d 100644 --- a/TAO/examples/Callback_Quoter/Consumer_Handler.cpp +++ b/TAO/examples/Callback_Quoter/Consumer_Handler.cpp @@ -206,7 +206,7 @@ Consumer_Handler::init (int argc, char **argv) -1); // Register the signal event handler for ^C - // and for the signal which occurs when a terminal + // and for the signal which occurs when a terminal window // is changed. ACE_NEW_RETURN (consumer_signal_handler_, diff --git a/TAO/examples/Callback_Quoter/Makefile b/TAO/examples/Callback_Quoter/Makefile index 2242a9612cf..bfb8c19d25d 100644 --- a/TAO/examples/Callback_Quoter/Makefile +++ b/TAO/examples/Callback_Quoter/Makefile @@ -20,6 +20,7 @@ PROG_SRCS = \ consumer.cpp \ supplier.cpp \ Supplier_i.cpp \ + Supplier_Timer_Handler.cpp\ notifier.cpp \ Notifier_Input_Handler.cpp \ Notifier_i.cpp \ @@ -45,6 +46,7 @@ MARKET_CLT_OBJS = \ NotifierC.o \ NotifierS.o \ Supplier_i.o \ + Supplier_Timer_Handler.o \ supplier.o \ ConsumerC.o\ ConsumerS.o \ @@ -1585,7 +1587,8 @@ realclean: clean $(TAO_ROOT)/orbsvcs/orbsvcs/CosNamingS_T.cpp \ $(TAO_ROOT)/orbsvcs/orbsvcs/CosNamingS.i \ $(TAO_ROOT)/orbsvcs/orbsvcs/Naming/Entries.h \ - NotifierC.h ConsumerC.h ConsumerC.i NotifierC.i + NotifierC.h ConsumerC.h ConsumerC.i NotifierC.i \ + Supplier_Timer_Handler.h .obj/Supplier_i.o .obj/Supplier_i.so .shobj/Supplier_i.o .shobj/Supplier_i.so: Supplier_i.cpp \ $(ACE_ROOT)/ace/Get_Opt.h \ $(ACE_ROOT)/ace/ACE.h \ @@ -1843,7 +1846,8 @@ realclean: clean $(TAO_ROOT)/orbsvcs/orbsvcs/CosNamingS_T.cpp \ $(TAO_ROOT)/orbsvcs/orbsvcs/CosNamingS.i \ $(TAO_ROOT)/orbsvcs/orbsvcs/Naming/Entries.h \ - NotifierC.h ConsumerC.h ConsumerC.i NotifierC.i + NotifierC.h ConsumerC.h ConsumerC.i NotifierC.i \ + Supplier_Timer_Handler.h .obj/notifier.o .obj/notifier.so .shobj/notifier.o .shobj/notifier.so: notifier.cpp Notifier_Input_Handler.h Notifier_i.h \ NotifierS.h ConsumerS.h ConsumerC.h \ $(TAO_ROOT)/tao/corba.h \ @@ -2085,7 +2089,8 @@ realclean: clean $(TAO_ROOT)/tao/DynAny_i.h \ ConsumerC.i ConsumerS_T.h ConsumerS_T.i ConsumerS_T.cpp ConsumerS.i \ NotifierC.h NotifierC.i NotifierS_T.h NotifierS_T.i NotifierS_T.cpp \ - NotifierS.i $(TAO_ROOT)/tao/TAO.h \ + NotifierS.i \ + $(TAO_ROOT)/tao/TAO.h \ $(TAO_ROOT)/orbsvcs/orbsvcs/CosNamingS.h \ $(TAO_ROOT)/orbsvcs/orbsvcs/CosNamingC.h \ $(TAO_ROOT)/orbsvcs/orbsvcs/orbsvcs_export.h \ @@ -2344,7 +2349,8 @@ realclean: clean $(TAO_ROOT)/tao/DynAny_i.h \ ConsumerC.i ConsumerS_T.h ConsumerS_T.i ConsumerS_T.cpp ConsumerS.i \ NotifierC.h NotifierC.i NotifierS_T.h NotifierS_T.i NotifierS_T.cpp \ - NotifierS.i $(TAO_ROOT)/tao/TAO.h \ + NotifierS.i \ + $(TAO_ROOT)/tao/TAO.h \ $(TAO_ROOT)/orbsvcs/orbsvcs/CosNamingS.h \ $(TAO_ROOT)/orbsvcs/orbsvcs/CosNamingC.h \ $(TAO_ROOT)/orbsvcs/orbsvcs/orbsvcs_export.h \ @@ -2602,7 +2608,8 @@ realclean: clean $(TAO_ROOT)/tao/DynAny_i.h \ ConsumerC.i ConsumerS_T.h ConsumerS_T.i ConsumerS_T.cpp ConsumerS.i \ NotifierC.h NotifierC.i NotifierS_T.h NotifierS_T.i NotifierS_T.cpp \ - NotifierS.i $(TAO_ROOT)/tao/TAO.h + NotifierS.i \ + $(TAO_ROOT)/tao/TAO.h .obj/Consumer_i.o .obj/Consumer_i.so .shobj/Consumer_i.o .shobj/Consumer_i.so: Consumer_i.cpp Consumer_i.h ConsumerS.h ConsumerC.h \ $(TAO_ROOT)/tao/corba.h \ $(TAO_ROOT)/tao/orbconf.h \ diff --git a/TAO/examples/Callback_Quoter/Notifier_i.cpp b/TAO/examples/Callback_Quoter/Notifier_i.cpp index 0cd6e0940f0..cf4f38a3899 100644 --- a/TAO/examples/Callback_Quoter/Notifier_i.cpp +++ b/TAO/examples/Callback_Quoter/Notifier_i.cpp @@ -203,9 +203,7 @@ Notifier_i::market_status (const char *stock_name, void Notifier_i::shutdown (CORBA::Environment &env) { - ACE_DEBUG ((LM_DEBUG, - "The Callback Quoter server is shutting down...")); - + /* CONSUMERS *consumers; for (CONSUMER_MAP::ITERATOR iter = this->consumer_map_.begin (); iter!= this->consumer_map_.end (); @@ -236,10 +234,14 @@ Notifier_i::shutdown (CORBA::Environment &env) ACE_DEBUG ((LM_DEBUG, " All consumers removed!\n"));*/ - if ( this->consumer_map_.close () == -1) + if ( this->consumer_map_.close () > 0) ACE_ERROR ((LM_ERROR, "Consumer_map_close error!\n")); + ACE_DEBUG ((LM_DEBUG, + "The Callback Quoter server is shutting down...")); + + // Instruct the ORB to shutdown. this->orb_->shutdown (); diff --git a/TAO/examples/Callback_Quoter/Notifier_i.h b/TAO/examples/Callback_Quoter/Notifier_i.h index 65041100450..2f920c634ef 100644 --- a/TAO/examples/Callback_Quoter/Notifier_i.h +++ b/TAO/examples/Callback_Quoter/Notifier_i.h @@ -71,7 +71,7 @@ public: //private: public: - CORBA::ORB_var orb_; + CORBA::ORB_ptr orb_; // The ORB manager. class Consumer_Data diff --git a/TAO/examples/Callback_Quoter/Supplier_i.cpp b/TAO/examples/Callback_Quoter/Supplier_i.cpp index c52da4616e2..bbeeb5664f6 100644 --- a/TAO/examples/Callback_Quoter/Supplier_i.cpp +++ b/TAO/examples/Callback_Quoter/Supplier_i.cpp @@ -1,10 +1,26 @@ // $Id$ +// =========================================================== +// +// +// = LIBRARY +// TAO/examples/Callback_Quoter +// +// = FILENAME +// Supplier_i.cpp +// +// = DESCRIPTION +// Implementation of the Supplier class. +// +// = AUTHOR +// Kirthika Parameswaran <kirthika@cs.wustl.edu> +// +// =========================================================== #include "ace/Get_Opt.h" #include "ace/Read_Buffer.h" +#include "ace/OS.h" #include "Supplier_i.h" - -ACE_RCSID(Callback_Quoter, Supplier, "$Id$") +#include "ace/Reactor.h" // Constructor. @@ -21,6 +37,8 @@ Supplier::~Supplier (void) ACE_OS::free (this->ior_); ACE_DEBUG ((LM_DEBUG, "Market Status Supplier daemon exiting!\n")); + + } // Reads the Server factory IOR from a file. @@ -34,15 +52,16 @@ Supplier::read_ior (char *filename) if (f_handle == ACE_INVALID_HANDLE) ACE_ERROR_RETURN ((LM_ERROR, "Unable to open %s for writing: %p\n", - filename), - -1); + filename,"file_open"), + -1); ACE_Read_Buffer ior_buffer (f_handle); char *data = ior_buffer.read (); if (data == 0) ACE_ERROR_RETURN ((LM_ERROR, - "Unable to read ior: %p\n"), + "Unable to read ior: %p\n", + "read_file"), -1); this->ior_ = ACE_OS::strdup (data); @@ -83,7 +102,8 @@ Supplier::parse_args (void) if (result < 0) ACE_ERROR_RETURN ((LM_ERROR, "Unable to read ior from %s : %p\n", - get_opts.optarg), + get_opts.optarg, + "get_args"), -1); break; @@ -140,9 +160,29 @@ Supplier::send_market_status (const char *stock_name, int Supplier::run (void) { + + long timer_id = 0; + ACE_DEBUG ((LM_DEBUG, "Market Status Supplier Daemon is running...\n ")); + + ACE_Time_Value period (1); + + + timer_id = reactor_used ()->schedule_timer (supplier_timer_handler_, + "Periodic stockfeed", + period, + period); + if ( timer_id== -1) + ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "schedule_timer"), -1); + + // ACE_DEBUG ((LM_DEBUG, + // "cancelling timer\n")); + // this->reactor_used ()->cancel_timer (timer_id); + + /* + // @@ Ultimately, let's replace this with an ACE_OS::sleep() call or // something. for (;;) @@ -158,10 +198,12 @@ Supplier::run (void) if (this->send_market_status (stock_name, value) < 0) break; } - + */ + this->reactor_used ()->run_event_loop (); return 0; } + int Supplier::via_naming_service (void) { @@ -209,6 +251,13 @@ Supplier::init (int argc, char **argv) TAO_TRY { + + // Create the Timer_Handler. + ACE_NEW_RETURN (supplier_timer_handler_, + Supplier_Timer_Handler (this,this->reactor_used ()), + -1); + + // Retrieve the ORB. this->orb_ = CORBA::ORB_init (this->argc_, this->argv_, @@ -255,3 +304,10 @@ Supplier::init (int argc, char **argv) return 0; } + + +ACE_Reactor* +Supplier::reactor_used (void) const +{ + return (ACE_Reactor::instance ()); +} diff --git a/TAO/examples/Callback_Quoter/Supplier_i.h b/TAO/examples/Callback_Quoter/Supplier_i.h index f60eb0fa2bb..7e18acbcf9e 100644 --- a/TAO/examples/Callback_Quoter/Supplier_i.h +++ b/TAO/examples/Callback_Quoter/Supplier_i.h @@ -1,6 +1,5 @@ // -*- C++ -*- // $Id$ - // ============================================================================ // // = LIBRARY @@ -17,11 +16,22 @@ // Kirthika Parameswaran <kirthika@cs.wustl.edu> // // ============================================================================ +#ifndef SUPPLIER_I_H +#define SUPPLIER_I_H #include "orbsvcs/Naming/Naming_Utils.h" #include "orbsvcs/CosNamingC.h" +#include "ace/Reactor.h" #include "NotifierC.h" +#include "Supplier_Timer_Handler.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ +// This class does the job of feeding the Callback Quoter +// notifier with stock information. +class Supplier_Timer_Handler; class Supplier { // = TITLE @@ -29,7 +39,7 @@ class Supplier // // = DESCRIPTION // Class wrapper for a daemon which keeps sending - // current stock values to the Callback Quoter server. + // current stock values to the Callback Quoter notifier. public: // = Initialization and termination methods. Supplier (void); @@ -44,6 +54,14 @@ public: int init (int argc, char *argv[]); // Initialize the client communication endpoint with Notifier. + int send_market_status (const char *stock_name, + long value); + // Sends the stock name and its value. + + Supplier_Timer_Handler *supplier_timer_handler_; + // The timer handler used to send the market status to the + // notifier periodically. + private: int read_ior (char *filename); // Function to read the Notifier IOR from a file. @@ -54,10 +72,9 @@ private: int via_naming_service(void); // This method initialises the naming service and registers the // object with the POA. - - int send_market_status (const char *stock_name, - long value); - // Sends the stock name and its value. + + ACE_Reactor *reactor_used (void) const; + // returns the TAO instance of the singleton Reactor. int argc_; // # of arguments on the command line. @@ -91,3 +108,5 @@ private: int loop_count_; // Iteration count. }; + +#endif /*SUPPLIER_I_H */ |