Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/babylon/concurrent/bounded_queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,14 +465,14 @@ template <typename U, typename ::std::enable_if<
::std::is_assignable<T&, U>::value, int>::type>
inline bool ABSL_ATTRIBUTE_ALWAYS_INLINE
ConcurrentBoundedQueue<T, S>::try_push(U&& value) noexcept {
return try_push<true, true, true>(::std::forward<U>(value));
return try_push<true, true>(::std::forward<U>(value));
}

template <typename T, typename S>
template <typename C, typename>
inline bool ABSL_ATTRIBUTE_ALWAYS_INLINE
ConcurrentBoundedQueue<T, S>::try_push(C&& callback) noexcept {
return try_push<true, true, true>(::std::forward<C>(callback));
return try_push<true, true>(::std::forward<C>(callback));
}

template <typename T, typename S>
Expand Down
16 changes: 16 additions & 0 deletions test/concurrent/test_bounded_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,22 @@ TEST(concurrent_bounded_queue, try_pop_fail_on_empty) {
ASSERT_EQ("10010", s);
}

TEST(concurrent_bounded_queue, try_push_default_overload) {
ConcurrentBoundedQueue<::std::string> queue(1);
ASSERT_TRUE(queue.try_push("10086"));
ASSERT_FALSE(queue.try_push("10010"));
::std::string s;
ASSERT_TRUE(queue.try_pop(s));
ASSERT_EQ("10086", s);
bool called = false;
ASSERT_TRUE(queue.try_push([&](::std::string& value) {
called = true;
value = "10010";
}));
ASSERT_TRUE(called);
ASSERT_TRUE(queue.try_pop(s));
}

TEST(concurrent_bounded_queue, try_pop_wakeup_blocking_push) {
ConcurrentBoundedQueue<::std::string> queue;
queue.push("10086");
Expand Down
Loading