| 49 | } |
| 50 | |
| 51 | int |
| 52 | Writer::svc() |
| 53 | { |
| 54 | DDS::InstanceHandleSeq handles; |
| 55 | |
| 56 | try { |
| 57 | // Block until Subscriber is available |
| 58 | DDS::StatusCondition_var condition = writer_->get_statuscondition(); |
| 59 | condition->set_enabled_statuses(DDS::PUBLICATION_MATCHED_STATUS); |
| 60 | |
| 61 | DDS::WaitSet_var ws = new DDS::WaitSet; |
| 62 | ws->attach_condition(condition); |
| 63 | ws->attach_condition(guard_condition_); |
| 64 | const DDS::Duration_t timeout = { 1 , 0 }; |
| 65 | |
| 66 | DDS::ConditionSeq conditions; |
| 67 | DDS::PublicationMatchedStatus matches = {0, 0, 0, 0, 0}; |
| 68 | |
| 69 | if (writer_->get_publication_matched_status(matches) != ::DDS::RETCODE_OK) { |
| 70 | ACE_ERROR((LM_ERROR, |
| 71 | ACE_TEXT("%N:%l: svc()") |
| 72 | ACE_TEXT(" ERROR: get_publication_matched_status failed!\n"))); |
| 73 | ACE_OS::exit(1); |
| 74 | } |
| 75 | |
| 76 | while (matches.current_count < 1) { |
| 77 | DDS::ReturnCode_t ret = ws->wait(conditions, timeout); |
| 78 | |
| 79 | if (ret != DDS::RETCODE_OK && ret != DDS::RETCODE_TIMEOUT) { |
| 80 | ACE_ERROR((LM_ERROR, |
| 81 | ACE_TEXT("%N:%l: svc()") |
| 82 | ACE_TEXT(" ERROR: wait failed!\n"))); |
| 83 | ACE_OS::exit(1); |
| 84 | } |
| 85 | |
| 86 | for (unsigned i = 0; i < conditions.length(); i++) { |
| 87 | if (conditions[i] == guard_condition_) { |
| 88 | ACE_DEBUG((LM_DEBUG, ACE_TEXT("match timed out\n"))); |
| 89 | return 0; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | if (writer_->get_publication_matched_status(matches) != ::DDS::RETCODE_OK) { |
| 94 | ACE_ERROR((LM_ERROR, |
| 95 | ACE_TEXT("%N:%l: svc()") |
| 96 | ACE_TEXT(" ERROR: get_publication_matched_status failed!\n"))); |
| 97 | ACE_OS::exit(1); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | ws->detach_condition(condition); |
| 102 | ws->detach_condition(guard_condition_); |
| 103 | if (args_.secure_part_user_data_) { |
| 104 | // Give secure participant writer time to send |
| 105 | ACE_OS::sleep(3); |
| 106 | } |
| 107 | |
| 108 | // Write samples |
nothing calls this directly
no test coverage detected