diff --git a/src/babylon/concurrent/bounded_queue.hpp b/src/babylon/concurrent/bounded_queue.hpp index b67a9d4..da6ee67 100644 --- a/src/babylon/concurrent/bounded_queue.hpp +++ b/src/babylon/concurrent/bounded_queue.hpp @@ -465,14 +465,14 @@ template ::value, int>::type> inline bool ABSL_ATTRIBUTE_ALWAYS_INLINE ConcurrentBoundedQueue::try_push(U&& value) noexcept { - return try_push(::std::forward(value)); + return try_push(::std::forward(value)); } template template inline bool ABSL_ATTRIBUTE_ALWAYS_INLINE ConcurrentBoundedQueue::try_push(C&& callback) noexcept { - return try_push(::std::forward(callback)); + return try_push(::std::forward(callback)); } template diff --git a/test/concurrent/test_bounded_queue.cpp b/test/concurrent/test_bounded_queue.cpp index 3acbf4a..229e7c9 100644 --- a/test/concurrent/test_bounded_queue.cpp +++ b/test/concurrent/test_bounded_queue.cpp @@ -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");