MCPcopy Create free account
hub / github.com/COVESA/vsomeip / send_request

Method send_request

test/network_tests/memory_tests/memory_test_client.cpp:91–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91void memory_test_client::send_request(std::atomic<bool>& stop_checking_) {
92 std::unique_lock lk(availability_mutex);
93 // Only send the requests when the service availability is secured
94 if (condition_availability.wait_for(lk, WAIT_AVAILABILITY, [this] { return availability; })) {
95
96 // Trigger the test
97 auto its_message = vsomeip_utilities::create_standard_vsip_request(MEMORY_SERVICE, MEMORY_INSTANCE, MEMORY_START_METHOD,
98 MEMORY_MAJOR, vsomeip::message_type_e::MT_REQUEST_NO_RETURN);
99 _app->send(its_message);
100 }
101
102 EXPECT_TRUE(availability) << "Events expected by the client were not available for 15 seconds ";
103
104 bool stop_watchdog{false};
105 uint64_t prev_counter{0};
106 auto prev_time = std::chrono::steady_clock::now();
107
108 // 3. Wait for service to send all the messages
109 while (!stop_watchdog) {
110 std::this_thread::sleep_for(WATCHDOG_INTERVAL);
111 auto now = std::chrono::steady_clock::now();
112 double elapsed_s = std::chrono::duration<double>(now - prev_time).count();
113
114 uint64_t current_counter{0};
115 bool timed_out{false};
116 {
117 std::scoped_lock lk(event_counter_mutex);
118 current_counter = received_messages_counter;
119 timed_out = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - sec).count() > 10;
120 }
121
122 uint64_t delta = current_counter - prev_counter;
123 double throughput_mbs = (static_cast<double>(delta) * NOTIFY_PAYLOAD_SIZE) / elapsed_s / (1024.0 * 1024.0);
124
125 VSOMEIP_INFO << "[watchdog] messages in last " << std::fixed << std::setprecision(1) << elapsed_s << "s: " << delta
126 << " | throughput: " << std::fixed << std::setprecision(2) << throughput_mbs << " MB/s"
127 << " | total received: " << current_counter;
128
129 prev_counter = current_counter;
130 prev_time = now;
131
132 if (timed_out) {
133 stop_watchdog = true;
134 }
135 }
136 VSOMEIP_INFO << "received " << received_messages_counter;
137 stop_checking_ = true;
138}
139
140void memory_test_client::unsubscribe_all() {
141 _app->unsubscribe(MEMORY_SERVICE, MEMORY_INSTANCE, MEMORY_EVENTGROUP);

Callers 1

TESTFunction · 0.45

Calls 4

wait_forMethod · 0.80
countMethod · 0.80
sendMethod · 0.45

Tested by

no test coverage detected