diff options
author | msmit <msmit@remedy.nl> | 2009-11-09 11:48:50 +0000 |
---|---|---|
committer | msmit <msmit@remedy.nl> | 2009-11-09 11:48:50 +0000 |
commit | b903e9b73215984a9e719c10d76431908ae26fbc (patch) | |
tree | 1f546a29d867e92607e5278309d9562f6fa70024 | |
parent | c5bc97d9d405e8cb612c42e3b6541a1dd5e05771 (diff) | |
download | ATCD-b903e9b73215984a9e719c10d76431908ae26fbc.tar.gz |
Mon Nov 9 11:46:44 UTC 2009 Marcel Smit <msmit@remedy.nl>
* connectors/dds4ccm/examples/Hello/Sender/Hello_Sender_exec.cpp:
Resolved unicode compiler error.
* connectors/dds4ccm/examples/Shapes/Receiver/Receiver_exec.h:
* connectors/dds4ccm/examples/Shapes/Receiver/Receiver_exec.cpp:
* connectors/dds4ccm/examples/Shapes/Sender/Sender_exec.h:
* connectors/dds4ccm/examples/Shapes/Sender/Sender_exec.cpp:
Removed thread. Using the ORB reactor thread to generate
and receive ShapeTypes.
* examples/Hello/Sender/Sender_exec.cpp:
Resolved unicode compiler error.
7 files changed, 65 insertions, 248 deletions
diff --git a/CIAO/ChangeLog b/CIAO/ChangeLog index 1b11777f852..2e703001d93 100644 --- a/CIAO/ChangeLog +++ b/CIAO/ChangeLog @@ -1,3 +1,18 @@ +Mon Nov 9 11:46:44 UTC 2009 Marcel Smit <msmit@remedy.nl> + + * connectors/dds4ccm/examples/Hello/Sender/Hello_Sender_exec.cpp: + Resolved unicode compiler error. + + * connectors/dds4ccm/examples/Shapes/Receiver/Receiver_exec.h: + * connectors/dds4ccm/examples/Shapes/Receiver/Receiver_exec.cpp: + * connectors/dds4ccm/examples/Shapes/Sender/Sender_exec.h: + * connectors/dds4ccm/examples/Shapes/Sender/Sender_exec.cpp: + Removed thread. Using the ORB reactor thread to generate + and receive ShapeTypes. + + * examples/Hello/Sender/Sender_exec.cpp: + Resolved unicode compiler error. + Mon Nov 9 09:49:35 UTC 2009 Johnny Willemsen <jwillemsen@remedy.nl> * connectors/dds4ccm/examples/Shapes/Connector/Shapes_Connector.idl3 diff --git a/CIAO/connectors/dds4ccm/examples/Hello/Sender/Hello_Sender_exec.cpp b/CIAO/connectors/dds4ccm/examples/Hello/Sender/Hello_Sender_exec.cpp index 3ce0fc0229e..333ab6a6e1a 100644 --- a/CIAO/connectors/dds4ccm/examples/Hello/Sender/Hello_Sender_exec.cpp +++ b/CIAO/connectors/dds4ccm/examples/Hello/Sender/Hello_Sender_exec.cpp @@ -69,7 +69,7 @@ namespace CIAO_Hello_DDS_Sender_Impl { if (!this->log_time_) return msg; - ACE_TCHAR timestamp[16]; + char timestamp[16]; ACE_Date_Time now; ACE_OS::sprintf (timestamp, "%02d.%d", diff --git a/CIAO/connectors/dds4ccm/examples/Shapes/Receiver/Receiver_exec.cpp b/CIAO/connectors/dds4ccm/examples/Shapes/Receiver/Receiver_exec.cpp index d0d97f76f10..c5e4879538b 100644 --- a/CIAO/connectors/dds4ccm/examples/Shapes/Receiver/Receiver_exec.cpp +++ b/CIAO/connectors/dds4ccm/examples/Shapes/Receiver/Receiver_exec.cpp @@ -4,15 +4,13 @@ #include "Receiver_exec.h" #include "ciao/Logger/Log_Macros.h" +#include "tao/ORB_Core.h" namespace CIAO_Shapes_Receiver_Impl { read_action_Generator::read_action_Generator (Receiver_exec_i &callback) - : active_ (0), - pulse_callback_ (callback) + : pulse_callback_ (callback) { - // initialize the reactor - this->reactor (ACE_Reactor::instance ()); } read_action_Generator::~read_action_Generator () @@ -20,82 +18,6 @@ namespace CIAO_Shapes_Receiver_Impl } int - read_action_Generator::open_h () - { - // convert the task into a active object that runs in separate thread - return this->activate (); - } - - int - read_action_Generator::close_h () - { - this->reactor ()->end_reactor_event_loop (); - // wait for all threads in the task to exit before it returns - return this->wait (); - } - - int - read_action_Generator::start (CORBA::ULong hertz) - { - // return if not valid - if (hertz == 0 || this->active_ != 0) - { - return -1; - } - - // calculate the interval time - long usec = 1000000 / hertz; - - std::cerr << "Starting read_action_generator with hertz of " << hertz << ", interval of " - << usec << std::endl; - - if (this->reactor ()->schedule_timer (this, - 0, - ACE_Time_Value(0), - ACE_Time_Value(3)) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "Unable to setup Timer\n"), - -1); - } - - this->active_ = 1; - return 0; - } - - int - read_action_Generator::stop (void) - { - // return if not valid. - if (this->active_ == 0) - { - return -1; - } - // cancle the timer - this->reactor ()->cancel_timer (this); - this->active_ = 0; - return 0; - } - - int - read_action_Generator::active (void) - { - return this->active_; - } - - int - read_action_Generator::handle_close (ACE_HANDLE handle, - ACE_Reactor_Mask close_mask) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("[%x] handle = %d, close_mask = %d\n"), - this, - handle, - close_mask)); - return 0; - } - - int read_action_Generator::handle_timeout (const ACE_Time_Value &, const void *) { @@ -112,18 +34,6 @@ namespace CIAO_Shapes_Receiver_Impl return 0; } - int - read_action_Generator::svc (void) - { - // define the owner of the reactor thread - this->reactor ()->owner (ACE_OS::thr_self ()); - - // run event loop to wait for event, and then dispatch them to corresponding handlers - this->reactor ()->run_reactor_event_loop (); - - return 0; - } - //============================================================ // Facet Executor Implementation Class: ShapeType_RawListener_exec_i //============================================================ @@ -407,19 +317,28 @@ namespace CIAO_Shapes_Receiver_Impl throw CORBA::INTERNAL (); } lc->enabled (this->raw_listen_); - this->ticker_->start (this->rate_); + + // calculate the interval time + long usec = 1000000 / this->rate_; + if (this->context_->get_CCM_object()->_get_orb ()->orb_core ()->reactor ()->schedule_timer ( + this->ticker_, + 0, + ACE_Time_Value(0, usec), + ACE_Time_Value(0, usec)) == -1) + { + CIAO_ERROR ((LM_ERROR, "Unable to schedule Timer\n")); + } } void Receiver_exec_i::ccm_passivate (void) { - this->ticker_->stop (); + this->context_->get_CCM_object()->_get_orb ()->orb_core ()->reactor ()->cancel_timer (this->ticker_); } void Receiver_exec_i::ccm_remove (void) { - this->ticker_->close_h (); } extern "C" RECEIVER_EXEC_Export ::Components::EnterpriseComponent_ptr diff --git a/CIAO/connectors/dds4ccm/examples/Shapes/Receiver/Receiver_exec.h b/CIAO/connectors/dds4ccm/examples/Shapes/Receiver/Receiver_exec.h index 59717a85b06..ecbc411ebae 100644 --- a/CIAO/connectors/dds4ccm/examples/Shapes/Receiver/Receiver_exec.h +++ b/CIAO/connectors/dds4ccm/examples/Shapes/Receiver/Receiver_exec.h @@ -55,44 +55,19 @@ namespace CIAO_Shapes_Receiver_Impl * @brief an active object used by Receiver to perform a periodical read action * */ - class read_action_Generator : public ACE_Task_Base + class read_action_Generator + : public ACE_Event_Handler { public: read_action_Generator (Receiver_exec_i &callback); ~read_action_Generator (); - /// Hook method that performs application-defined initialization activities - int open_h (void); - - /// Hook method that performs application-defined destruction activites - int close_h (void); - - /// appliation-defined method for starting the pulse-generation service - int start (CORBA::ULong hertz); - - /// application-defined method for stopping the pulse-generation service - int stop (void); - - /// Indicate whether the current object is active - int active (void); - /// Handle the timeout. virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg); - /// Called when timer handler is removed. - virtual int handle_close (ACE_HANDLE handle, - ACE_Reactor_Mask close_mask); - - /// Hook methods implemnting the task's service processing, - /// invoked by all threads activated by activate () method - virtual int svc (void); - private: - /// Tracking whether we are actively generating pulse or not. - int active_; - /// Maintains a handle that actually process the event Receiver_exec_i &pulse_callback_; diff --git a/CIAO/connectors/dds4ccm/examples/Shapes/Sender/Sender_exec.cpp b/CIAO/connectors/dds4ccm/examples/Shapes/Sender/Sender_exec.cpp index 84f1b88d040..45fb083258c 100644 --- a/CIAO/connectors/dds4ccm/examples/Shapes/Sender/Sender_exec.cpp +++ b/CIAO/connectors/dds4ccm/examples/Shapes/Sender/Sender_exec.cpp @@ -4,6 +4,7 @@ #include "Sender_exec.h" #include "ace/Guard_T.h" #include "ciao/Logger/Log_Macros.h" +#include "tao/ORB_Core.h" namespace CIAO_Shapes_Sender_Impl { @@ -12,11 +13,8 @@ namespace CIAO_Shapes_Sender_Impl //============================================================ pulse_Generator::pulse_Generator (Sender_exec_i &callback) - : active_ (0), - pulse_callback_ (callback) + : pulse_callback_ (callback) { - // initialize the reactor - this->reactor (ACE_Reactor::instance ()); } pulse_Generator::~pulse_Generator () @@ -24,82 +22,6 @@ namespace CIAO_Shapes_Sender_Impl } int - pulse_Generator::open_h () - { - // convert the task into a active object that runs in separate thread - return this->activate (); - } - - int - pulse_Generator::close_h () - { - this->reactor ()->end_reactor_event_loop (); - - // wait for all threads in the task to exit before it returns - return this->wait (); - } - - int - pulse_Generator::start (CORBA::ULong hertz) - { - // return if not valid - if (hertz == 0 || this->active_ != 0) - { - return -1; - } - - // calculate the interval time - long usec = 1000000 / hertz; - - std::cerr << "Starting pulse_generator with hertz of " << hertz << ", interval of " - << usec << std::endl; - - if (this->reactor ()->schedule_timer (this, - 0, - ACE_Time_Value (0, usec), - ACE_Time_Value (0, usec)) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "Unable to setup Timer\n"), - -1); - } - this->active_ = 1; - return 0; - } - - int - pulse_Generator::stop (void) - { - // return if not valid. - if (this->active_ == 0) - { - return -1; - } - // cancle the timer - this->reactor ()->cancel_timer (this); - this->active_ = 0; - return 0; - } - - int - pulse_Generator::active (void) - { - return this->active_; - } - - int - pulse_Generator::handle_close (ACE_HANDLE handle, - ACE_Reactor_Mask close_mask) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("[%x] handle = %d, close_mask = %d\n"), - this, - handle, - close_mask)); - return 0; - } - - int pulse_Generator::handle_timeout (const ACE_Time_Value &, const void *) { @@ -108,18 +30,6 @@ namespace CIAO_Shapes_Sender_Impl return 0; } - int - pulse_Generator::svc (void) - { - // define the owner of the reactor thread - this->reactor ()->owner (ACE_OS::thr_self ()); - - // run event loop to wait for event, and then dispatch them to corresponding handlers - this->reactor ()->run_reactor_event_loop (); - - return 0; - } - //============================================================ // Component Executor Implementation Class: Sender_exec_i //============================================================ @@ -204,13 +114,38 @@ namespace CIAO_Shapes_Sender_Impl void Sender_exec_i::start (void) { - this->ticker_->start (this->rate_); + // calculate the interval time + long usec = 1000000 / this->rate_; + if (!this->context_->get_CCM_object()->_get_orb ()->orb_core ()->reactor ()->schedule_timer ( + this->ticker_, + 0, + ACE_Time_Value (0, usec), + ACE_Time_Value (0, usec)) == -1) + { + CIAO_ERROR ((LM_ERROR, ACE_TEXT ("Sender_exec_i::start : ") + ACE_TEXT ("Error scheduling timer"))); + } } void Sender_exec_i::stop (void) { - this->ticker_->stop (); + this->context_->get_CCM_object()->_get_orb ()->orb_core ()->reactor ()->cancel_timer (this->ticker_); + CIAO_DEBUG ((LM_DEBUG, ACE_TEXT ("Sender_exec_i::stop : Timer canceled.\n"))); + try + { + this->updater_->_cxx_delete (*this->square_); + } + catch (CCM_DDS::NonExistent& ) + { + CIAO_ERROR ((LM_ERROR, ACE_TEXT ("Shape_info for <%C> not deleted: <%C> didn't exist.\n"), + square_->color.in (), square_->color.in ())); + } + catch (CCM_DDS::InternalError& ) + { + CIAO_ERROR ((LM_ERROR, ACE_TEXT ("Internal Error while deleting Shape_info for <%C>.\n"), + square_->color.in ())); + } } // Component attributes. @@ -300,7 +235,6 @@ namespace CIAO_Shapes_Sender_Impl Sender_exec_i::configuration_complete (void) { this->updater_ = this->context_->get_connection_info_update_data (); - this->ticker_->activate (); } void @@ -337,6 +271,7 @@ namespace CIAO_Shapes_Sender_Impl void Sender_exec_i::ccm_passivate (void) { + this->stop (); } void diff --git a/CIAO/connectors/dds4ccm/examples/Shapes/Sender/Sender_exec.h b/CIAO/connectors/dds4ccm/examples/Shapes/Sender/Sender_exec.h index 46e8abf9c5d..8ee9b83fc0f 100644 --- a/CIAO/connectors/dds4ccm/examples/Shapes/Sender/Sender_exec.h +++ b/CIAO/connectors/dds4ccm/examples/Shapes/Sender/Sender_exec.h @@ -23,47 +23,20 @@ namespace CIAO_Shapes_Sender_Impl { class Sender_exec_i; - class pulse_Generator : public ACE_Task_Base + class pulse_Generator : + public ACE_Event_Handler { public: pulse_Generator (Sender_exec_i &callback); ~pulse_Generator (); - /// Hook method that performs application-defined initialization activities - int open_h (void); - - /// Hook method that performs application-defined destruction activites - int close_h (void); - - /// appliation-defined method for starting the pulse-generation service - int start (CORBA::ULong hertz); - - /// application-defined method for stopping the pulse-generation service - int stop (void); - - /// Indicate whether the current object is active - int active (void); - /// Handle the timeout. virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg); - - /// Called when timer handler is removed. - virtual int handle_close (ACE_HANDLE handle, - ACE_Reactor_Mask close_mask); - - /// Hook methods implemnting the task's service processing, - /// invoked by all threads activated by activate () method - virtual int svc (void); - private: - /// Tracking whether we are actively generating pulse or not. - int active_; - /// Maintains a handle that actually process the event Sender_exec_i &pulse_callback_; - }; class Sender_exec_i diff --git a/CIAO/examples/Hello/Sender/Sender_exec.cpp b/CIAO/examples/Hello/Sender/Sender_exec.cpp index 4c7cf53476c..972650085f3 100644 --- a/CIAO/examples/Hello/Sender/Sender_exec.cpp +++ b/CIAO/examples/Hello/Sender/Sender_exec.cpp @@ -33,7 +33,7 @@ namespace CIAO_Hello_Sender_Impl { //Add extra time ACE_hrtime_t start = ACE_OS::gethrtime(); - ACE_TCHAR timestamp[16]; + char timestamp[16]; ACE_OS::sprintf (timestamp, "%lld", start); |