Closed phongt closed 3 years ago
@phongt Thanks for the hint!
Actually this is not a problem here and we are not losing any samples. The single_process
example is just sending and receiving for a duration of 2 seconds. When the time is up the publisher
and subscriber
while loop is exited and the example terminates. Incidentally it coincides with the receiving of the 20th sample, this means that the subscriber loop is exited before it has a chance to receive the 20th sample.
If you adjust the line 131 (std::this_thread::sleep_for(std::chrono::seconds(2));
) so that the example runs infinitely you will see that everything is in order.
If you adjust the line 131 (std::this_thread::sleep_for(std::chrono::seconds(2));) so that the example runs infinitely you will see that everything is in order.
Thank you. I add the main loop and see more sending and receiving samples with this.
diff --git a/iceoryx_examples/singleprocess/single_process.cpp b/iceoryx_examples/singleprocess/single_process.cpp
index 9b8d026d..fe6a2a47 100644
--- a/iceoryx_examples/singleprocess/single_process.cpp
+++ b/iceoryx_examples/singleprocess/single_process.cpp
@@ -128,7 +128,8 @@ int main()
std::thread publisherThread(publisher), subscriberThread(subscriber);
// communicate for 2 seconds and then stop the example
- std::this_thread::sleep_for(std::chrono::seconds(2));
+ while(keepRunning)
+ std::this_thread::sleep_for(std::chrono::seconds(2));
keepRunning.store(false);
publisherThread.join();
Required information
Operating system: Debian 11 bullseye
Compiler version: gcc version 10.2.1 20210110 (Debian 10.2.1-6)
Observed result or behaviour: losing the last sample from single_process app
Expected result or behaviour: full samples should be rx
Conditions where it occurred / Performed steps:
Build the iceoryx with ./tools/iceoryx_build_test.sh clean debug examples build-test
./build/install/prefix/bin/single_process | grep Sending --> see 0 -> 19 were sending $ ./build/install/prefix/bin/single_process | grep Sending Log level set to: [ Error ] Reserving 60126248 bytes in the shared memory [/iceoryx_mgmt] [ Reserving shared memory successful ] Reserving 149264720 bytes in the shared memory [/phongtran] [ Reserving shared memory successful ] Sending -> 0 Sending -> 1 Sending -> 2 Sending -> 3 Sending -> 4 Sending -> 5 Sending -> 6 Sending -> 7 Sending -> 8 Sending -> 9 Sending -> 10 Sending -> 11 Sending -> 12 Sending -> 13 Sending -> 14 Sending -> 15 Sending -> 16 Sending -> 17 Sending -> 18 Sending -> 19
./build/install/prefix/bin/single_process | grep Receiving --> see 0 -> 18 was receiving $ ./build/install/prefix/bin/single_process | grep Receiving Log level set to: [ Error ] Reserving 60126248 bytes in the shared memory [/iceoryx_mgmt] [ Reserving shared memory successful ] Reserving 149264720 bytes in the shared memory [/phongtran] [ Reserving shared memory successful ] Receiving <- 0 Receiving <- 1 Receiving <- 2 Receiving <- 3 Receiving <- 4 Receiving <- 5 Receiving <- 6 Receiving <- 7 Receiving <- 8 Receiving <- 9 Receiving <- 10 Receiving <- 11 Receiving <- 12 Receiving <- 13 Receiving <- 14 Receiving <- 15 Receiving <- 16 Receiving <- 17 Receiving <- 18