MCPcopy Create free account
hub / github.com/OpenDDS/OpenDDS / execute

Method execute

performance-tests/bench/test_controller/ScenarioManager.cpp:249–419  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

247}
248
249void ScenarioManager::execute(const Bench::TestController::AllocatedScenario& allocated_scenario,
250 Bench::TestController::Report& report)
251{
252 using namespace std::chrono;
253 // Write Configs
254 if (dds_entities_.scenario_writer_impl_->write(allocated_scenario, DDS::HANDLE_NIL) != DDS::RETCODE_OK) {
255 throw std::runtime_error("Config Write Failed!");
256 }
257
258 DDS::Duration_t delay = { 3, 0 };
259 if (dds_entities_.scenario_writer_impl_->wait_for_acknowledgments(delay) != DDS::RETCODE_OK) {
260 throw std::runtime_error("Wait For Ack Failed");
261 }
262
263 AllocatedScenario temp = allocated_scenario;
264 temp.configs.length(0);
265 temp.launch_time = Builder::get_sys_time() + Builder::from_seconds(3);
266 std::cout << "Setting scenario launch_time to be 3 seconds from now: "
267 << iso8601(system_clock::now() + seconds(3)) << std::endl << std::endl;
268
269 // Write Configs
270 if (dds_entities_.scenario_writer_impl_->write(temp, DDS::HANDLE_NIL) != DDS::RETCODE_OK) {
271 throw std::runtime_error("Config Write Failed!");
272 }
273
274 if (dds_entities_.scenario_writer_impl_->wait_for_acknowledgments(delay) != DDS::RETCODE_OK) {
275 throw std::runtime_error("Wait For 'Launch Time' Ack Failed");
276 }
277
278 // Set up Waiting for Reading Reports or the Scenario Timeout
279 DDS::WaitSet_var wait_set = new DDS::WaitSet;
280 DDS::ReadCondition_var read_condition = dds_entities_.report_reader_impl_->create_readcondition(
281 DDS::ANY_SAMPLE_STATE, DDS::ANY_VIEW_STATE, DDS::ANY_INSTANCE_STATE);
282 wait_set->attach_condition(read_condition);
283 DDS::GuardCondition_var guard_condition = new DDS::GuardCondition;
284 wait_set->attach_condition(guard_condition);
285
286 // Timeout Thread
287 size_t reports_left = allocated_scenario.expected_process_reports;
288 report.missing_reports = static_cast<CORBA::ULong>(reports_left);
289 std::mutex reports_left_mutex;
290 std::condition_variable timeout_cv;
291 const std::chrono::seconds timeout(allocated_scenario.timeout + SCENARIO_TIMEOUT_GRACE_PERIOD);
292 std::shared_ptr<std::thread> timeout_thread;
293 if (timeout.count() > 0) {
294 timeout_thread.reset(new std::thread([&] {
295 std::unique_lock<std::mutex> lock(reports_left_mutex);
296 if (!timeout_cv.wait_for(lock, timeout, [&] {return reports_left == 0;})) {
297 guard_condition->set_trigger_value(true);
298 }
299 }));
300 }
301
302 // Wait for reports
303 size_t process_report_count = 0;
304 size_t parsed_worker_report_count = 0;
305 size_t parse_failures = 0;
306 size_t worker_failures = 0;

Callers

nothing calls this directly

Calls 15

get_sys_timeFunction · 0.85
from_secondsFunction · 0.85
iso8601Function · 0.85
growFunction · 0.85
json_2_idlFunction · 0.85
attach_conditionMethod · 0.80
set_trigger_valueMethod · 0.80
notify_allMethod · 0.80
detach_conditionMethod · 0.80
writeMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected