proxygen
UnboundedBlockingQueueTest.cpp File Reference

Go to the source code of this file.

Functions

 TEST (UnboundedQueuee, push_pop)
 
 TEST (UnboundedBlockingQueue, size)
 
 TEST (UnboundedBlockingQueue, concurrent_push_pop)
 

Function Documentation

TEST ( UnboundedQueuee  ,
push_pop   
)
TEST ( UnboundedBlockingQueue  ,
concurrent_push_pop   
)

Definition at line 37 of file UnboundedBlockingQueueTest.cpp.

References folly::UnboundedBlockingQueue< T >::add(), EXPECT_EQ, folly::Baton< MayBlock, Atom >::post(), folly::UnboundedBlockingQueue< T >::size(), folly::pushmi::detail::t, folly::UnboundedBlockingQueue< T >::take(), and folly::Baton< MayBlock, Atom >::wait().

37  {
39  Baton<> b1, b2;
40  std::thread t([&] {
41  b1.post();
42  EXPECT_EQ(42, q.take());
43  EXPECT_EQ(0, q.size());
44  b2.post();
45  });
46  b1.wait();
47  q.add(42);
48  b2.wait();
49  EXPECT_EQ(0, q.size());
50  t.join();
51 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
FOLLY_ALWAYS_INLINE void wait(const WaitOptions &opt=wait_options()) noexcept
Definition: Baton.h:170
void post() noexcept
Definition: Baton.h:123
BlockingQueueAddResult add(T item) override