Skip to content

Commit

Permalink
iox-eclipse-iceoryx#751 Replace adaptive_wait with Barrier
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Eltzschig <me@elchris.org>
  • Loading branch information
elfenpiff committed Jun 23, 2022
1 parent b303960 commit 34fd386
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class NamedPipe : public DesignPattern::Creation<NamedPipe, IpcChannelError>
static constexpr uint64_t MAX_MESSAGE_SIZE = 4U * 1024U;
static constexpr uint32_t MAX_NUMBER_OF_MESSAGES = 10U;
static_assert(MAX_NUMBER_OF_MESSAGES < IOX_SEM_VALUE_MAX,
"The maximum number of supported messages must be less to the maximum allowed semaphore value");
"The maximum number of supported messages must be less than the maximum allowed semaphore value");

static constexpr uint64_t NULL_TERMINATOR_SIZE = 0U;
static constexpr units::Duration CYCLE_TIME = units::Duration::fromMilliseconds(10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -595,14 +595,14 @@ TEST_F(PublisherSubscriberCommunication_test, PublisherDoesNotBlockAndDiscardsSa
EXPECT_FALSE(publisher->publishCopyOf("second hypnotoad ate it").has_error());

std::atomic_bool wasSampleDelivered{false};
std::atomic_bool isThreadStarted{false};
Barrier isThreadStarted(1U);
std::thread t1([&] {
isThreadStarted = true;
isThreadStarted.notify();
EXPECT_FALSE(publisher->publishCopyOf("third a tiny black hole smells like butter").has_error());
wasSampleDelivered.store(true);
});

iox::cxx::internal::adaptive_wait().wait_loop([&] { return !isThreadStarted.load(); });
isThreadStarted.wait();
t1.join();
EXPECT_TRUE(wasSampleDelivered.load());

Expand Down Expand Up @@ -665,16 +665,16 @@ TEST_F(PublisherSubscriberCommunication_test, MixedOptionsSetupWorksWithBlocking
EXPECT_FALSE(publisherNonBlocking->publishCopyOf("hypnotoad has a sister named hypnoodle").has_error());

std::atomic_bool wasSampleDelivered{false};
std::atomic_bool isThreadStarted{false};
Barrier isThreadStarted(1U);
std::thread t1([&] {
isThreadStarted = true;
isThreadStarted.notify();
EXPECT_FALSE(publisherBlocking->publishCopyOf("chucky is the only one who can ride the hypnotoad").has_error());
wasSampleDelivered.store(true);
});

constexpr int64_t TIMEOUT_IN_MS = 100;

iox::cxx::internal::adaptive_wait().wait_loop([&] { return !isThreadStarted.load(); });
isThreadStarted.wait();
std::this_thread::sleep_for(std::chrono::milliseconds(TIMEOUT_IN_MS));
EXPECT_FALSE(wasSampleDelivered.load());

Expand Down

0 comments on commit 34fd386

Please sign in to comment.