diff options
author | msmit <msmit@remedy.nl> | 2009-12-08 12:50:21 +0000 |
---|---|---|
committer | msmit <msmit@remedy.nl> | 2009-12-08 12:50:21 +0000 |
commit | 661d047de32bc2ae5edf8c652a00f81bc373814b (patch) | |
tree | 60d3ae9f96ec1749c5768ddb2a5d01dcbdec45a6 | |
parent | 48592b75e58f353e2240e4ee8beea6b34b12f611 (diff) | |
download | ATCD-661d047de32bc2ae5edf8c652a00f81bc373814b.tar.gz |
Tue Dec 8 12:51:33 UTC 2009 Marcel Smit <msmit@remedy.nl>
* connectors/dds4ccm/impl/ndds/Getter_T.h:
* connectors/dds4ccm/impl/ndds/Getter_T.cpp:
Using a local waitset in stead of a global one.
* connectors/dds4ccm/tests/Getter/Receiver/Getter_Test_Receiver_exec.cpp:
Optimized get_many.
-rw-r--r-- | CIAO/ChangeLog | 9 | ||||
-rw-r--r-- | CIAO/connectors/dds4ccm/impl/ndds/Getter_T.cpp | 60 | ||||
-rw-r--r-- | CIAO/connectors/dds4ccm/impl/ndds/Getter_T.h | 9 | ||||
-rw-r--r-- | CIAO/connectors/dds4ccm/tests/Getter/Receiver/Getter_Test_Receiver_exec.cpp | 9 |
4 files changed, 62 insertions, 25 deletions
diff --git a/CIAO/ChangeLog b/CIAO/ChangeLog index 90ac36caa9d..76562ebff37 100644 --- a/CIAO/ChangeLog +++ b/CIAO/ChangeLog @@ -1,3 +1,12 @@ +Tue Dec 8 12:51:33 UTC 2009 Marcel Smit <msmit@remedy.nl> + + * connectors/dds4ccm/impl/ndds/Getter_T.h: + * connectors/dds4ccm/impl/ndds/Getter_T.cpp: + Using a local waitset in stead of a global one. + + * connectors/dds4ccm/tests/Getter/Receiver/Getter_Test_Receiver_exec.cpp: + Optimized get_many. + Tue Dec 8 10:48:04 UTC 2009 Marcel Smit <msmit@remedy.nl> * bin/ciao_tests.lst: diff --git a/CIAO/connectors/dds4ccm/impl/ndds/Getter_T.cpp b/CIAO/connectors/dds4ccm/impl/ndds/Getter_T.cpp index 31bd77a2dab..510f0f90458 100644 --- a/CIAO/connectors/dds4ccm/impl/ndds/Getter_T.cpp +++ b/CIAO/connectors/dds4ccm/impl/ndds/Getter_T.cpp @@ -34,23 +34,10 @@ CIAO::DDS4CCM::RTI::Getter_T<DDS_TYPE, CCM_TYPE>::Getter_T ( } // Now create the waitset conditions - ws_ = new DDSWaitSet (); gd_ = new DDSGuardCondition (); rd_condition_ = this->impl_->create_readcondition (DDS_NOT_READ_SAMPLE_STATE, DDS_NEW_VIEW_STATE | DDS_NOT_NEW_VIEW_STATE, DDS_ALIVE_INSTANCE_STATE | DDS_NOT_ALIVE_INSTANCE_STATE); - DDS_ReturnCode_t retcode = ws_->attach_condition (gd_); - if (retcode != DDS_RETCODE_OK) - { - CIAO_ERROR ((LM_ERROR, CLINFO "GETTER: Unable to attach guard condition to waitset.\n")); - throw CCM_DDS::InternalError (retcode, 0); - } - retcode = ws_->attach_condition (rd_condition_); - if (retcode != DDS_RETCODE_OK) - { - CIAO_ERROR ((LM_ERROR, CLINFO "GETTER: Unable to attach read condition to waitset.\n")); - throw CCM_DDS::InternalError (retcode, 1); - } } // Implementation skeleton destructor @@ -58,18 +45,18 @@ template <typename DDS_TYPE, typename CCM_TYPE > CIAO::DDS4CCM::RTI::Getter_T<DDS_TYPE, CCM_TYPE>::~Getter_T (void) { CIAO_TRACE ("CIAO::DDS4CCM::RTI::Getter_T::~Getter_T"); - delete ws_; delete gd_; } template <typename DDS_TYPE, typename CCM_TYPE > bool CIAO::DDS4CCM::RTI::Getter_T<DDS_TYPE, CCM_TYPE>::wait ( + DDSWaitSet* ws, DDSConditionSeq& active_conditions) { DDS_Duration_t timeout; timeout <<= this->time_out_; - DDS_ReturnCode_t const retcode = ws_->wait (active_conditions, timeout); + DDS_ReturnCode_t const retcode = ws->wait (active_conditions, timeout); if (retcode == DDS_RETCODE_TIMEOUT) { CIAO_DEBUG ((LM_DEBUG, ACE_TEXT ("Getter: No data available after timeout.\n"))); @@ -79,6 +66,24 @@ CIAO::DDS4CCM::RTI::Getter_T<DDS_TYPE, CCM_TYPE>::wait ( } template <typename DDS_TYPE, typename CCM_TYPE > +void +CIAO::DDS4CCM::RTI::Getter_T<DDS_TYPE, CCM_TYPE>::configure_waitset (DDSWaitSet* ws) +{ + DDS_ReturnCode_t retcode = ws->attach_condition (gd_); + if (retcode != DDS_RETCODE_OK) + { + CIAO_ERROR ((LM_ERROR, CLINFO "GETTER: Unable to attach guard condition to waitset.\n")); + throw CCM_DDS::InternalError (retcode, 0); + } + retcode = ws->attach_condition (rd_condition_); + if (retcode != DDS_RETCODE_OK) + { + CIAO_ERROR ((LM_ERROR, CLINFO "GETTER: Unable to attach read condition to waitset.\n")); + throw CCM_DDS::InternalError (retcode, 1); + } +} + +template <typename DDS_TYPE, typename CCM_TYPE > bool CIAO::DDS4CCM::RTI::Getter_T<DDS_TYPE, CCM_TYPE>::get_many ( typename CCM_TYPE::seq_type::_out_type instances, @@ -87,9 +92,17 @@ CIAO::DDS4CCM::RTI::Getter_T<DDS_TYPE, CCM_TYPE>::get_many ( instances = new typename CCM_TYPE::seq_type; infos = new ::CCM_DDS::ReadInfoSeq; +// DDS_WaitSetProperty_t wsp; +// wsp.max_event_count = this->max_delivered_data_; + DDSWaitSet* ws = new DDSWaitSet (); + configure_waitset (ws); + DDSConditionSeq active_conditions; - if (!this->wait (active_conditions)) - return false; + if (!this->wait (ws, active_conditions)) + { + delete ws; + return false; + } ::DDS_Long max_samples = this->max_delivered_data_; if (max_samples == 0) @@ -129,6 +142,10 @@ CIAO::DDS4CCM::RTI::Getter_T<DDS_TYPE, CCM_TYPE>::get_many ( ++number_read; } } + CIAO_DEBUG ((LM_DEBUG, ACE_TEXT ("Getter_T::get_many: ") + ACE_TEXT ("read <%d> - valid <%d>\n"), + sample_info.length (), + number_read)); infos->length (number_read); instances->length (number_read); number_read = 0; @@ -152,6 +169,7 @@ CIAO::DDS4CCM::RTI::Getter_T<DDS_TYPE, CCM_TYPE>::get_many ( "Error while reading from DDS: <%C>\n", translate_retcode (retcode))); this->impl_->return_loan(data,sample_info); + delete ws; throw CCM_DDS::InternalError (retcode, 1); } @@ -163,6 +181,7 @@ CIAO::DDS4CCM::RTI::Getter_T<DDS_TYPE, CCM_TYPE>::get_many ( } } } + delete ws; return true; } @@ -174,8 +193,11 @@ CIAO::DDS4CCM::RTI::Getter_T<DDS_TYPE, CCM_TYPE>::get_one ( { an_instance = new typename DDS_TYPE::value_type; + DDSWaitSet* ws = new DDSWaitSet (); + configure_waitset (ws); + DDSConditionSeq active_conditions; - if (!this->wait (active_conditions)) + if (!this->wait (ws, active_conditions)) return false; DDS_SampleInfoSeq sample_info; @@ -215,6 +237,7 @@ CIAO::DDS4CCM::RTI::Getter_T<DDS_TYPE, CCM_TYPE>::get_one ( "Error while reading from DDS: <%C>\n", translate_retcode (retcode))); this->impl_->return_loan(data,sample_info); + delete ws; throw CCM_DDS::InternalError (retcode, 1); } @@ -227,6 +250,7 @@ CIAO::DDS4CCM::RTI::Getter_T<DDS_TYPE, CCM_TYPE>::get_one ( } } } + delete ws; return true; } diff --git a/CIAO/connectors/dds4ccm/impl/ndds/Getter_T.h b/CIAO/connectors/dds4ccm/impl/ndds/Getter_T.h index 52283f85840..3850c938a47 100644 --- a/CIAO/connectors/dds4ccm/impl/ndds/Getter_T.h +++ b/CIAO/connectors/dds4ccm/impl/ndds/Getter_T.h @@ -45,15 +45,16 @@ namespace CIAO virtual ::CCM_DDS::DataNumber_t max_delivered_data (void); virtual void max_delivered_data (::CCM_DDS::DataNumber_t max_delivered_data); private: - bool wait (DDSConditionSeq& active_conditions); - typename DDS_TYPE::data_reader *impl_; DDSQueryCondition* condition_; ::DDS::Duration_t time_out_; ::CCM_DDS::DataNumber_t max_delivered_data_; DDSGuardCondition* gd_; - DDSWaitSet* ws_; - DDSReadCondition* rd_condition_; + DDSReadCondition* rd_condition_; + + bool wait (DDSWaitSet* ws, + DDSConditionSeq& active_conditions); + void configure_waitset (DDSWaitSet* ws); }; } } diff --git a/CIAO/connectors/dds4ccm/tests/Getter/Receiver/Getter_Test_Receiver_exec.cpp b/CIAO/connectors/dds4ccm/tests/Getter/Receiver/Getter_Test_Receiver_exec.cpp index 7e79f6af1f3..731a01c2978 100644 --- a/CIAO/connectors/dds4ccm/tests/Getter/Receiver/Getter_Test_Receiver_exec.cpp +++ b/CIAO/connectors/dds4ccm/tests/Getter/Receiver/Getter_Test_Receiver_exec.cpp @@ -166,10 +166,13 @@ namespace CIAO_Getter_Test_Receiver_Impl void Receiver_exec_i::get_many (CORBA::Short keys , CORBA::Long iterations) { + CORBA::ULong expected = keys * iterations; + //ACE_OS::sleep (5); DDS::Duration_t to; to.sec = 10; to.nanosec = 0; this->getter_->time_out (to); + this->getter_->max_delivered_data (40); CIAO_DEBUG ((LM_DEBUG, CLINFO ACE_TEXT ("Receiver_exec_i::get_many: ") ACE_TEXT ("Start getting data from DDS: ") ACE_TEXT ("#keys <%d> - #iterations <%d> with timeout: ") @@ -183,13 +186,13 @@ namespace CIAO_Getter_Test_Receiver_Impl bool result = this->getter_->get_many (gettertest_seq, readinfo); if (result) { - if (gettertest_seq->length () != (keys * iterations)) + if (gettertest_seq->length () != expected) { CIAO_ERROR ((LM_ERROR, CLINFO ACE_TEXT ("Receiver_exec_i::get_many: ") ACE_TEXT ("Returned data : Didn't receive correct ") ACE_TEXT ("number of samples: ") ACE_TEXT ("expected <%d> - received <%d>\n"), - keys * iterations, + expected, gettertest_seq->length ())); } for (CORBA::ULong i = 0; i < gettertest_seq->length (); ++i) @@ -205,7 +208,7 @@ namespace CIAO_Getter_Test_Receiver_Impl CIAO_ERROR ((LM_ERROR, CLINFO ACE_TEXT ("ERROR: GET MANY: ") ACE_TEXT ("Time out while waiting for ") ACE_TEXT ("#iterations <%d>\n"), - iterations)); + expected)); } } |