| | |
| | | size_type i = 0; |
| | | do { |
| | | auto pos = tail(); |
| | | if (tail_.compare_exchange_strong(pos, Next(pos))) { |
| | | auto cur = buf[pos].load(); |
| | | r = Empty(cur) && buf[pos].compare_exchange_strong(cur, Enc(d)); |
| | | tail_.compare_exchange_strong(pos, Next(pos)); |
| | | } |
| | | } while (try_more && !r && ++i < capacity); |
| | | return r; |
| | | } |
| | |
| | | size_type i = 0; |
| | | do { |
| | | auto pos = head(); |
| | | if (head_.compare_exchange_strong(pos, Next(pos))) { |
| | | cur = buf[pos].load(); |
| | | r = !Empty(cur) && buf[pos].compare_exchange_strong(cur, 0); |
| | | head_.compare_exchange_strong(pos, Next(pos)); |
| | | } |
| | | } while (try_more && !r && ++i < capacity); |
| | | if (r) { d = Dec(cur); } |
| | | return r; |
| | |
| | | BOOST_AUTO_TEST_CASE(QueueTest) |
| | | { |
| | | const int nthread = 100; |
| | | const uint64_t nmsg = 1000 * 1000 * 10; |
| | | const uint64_t nmsg = 1000 * 1000 * 100; |
| | | |
| | | SharedMemory &shm = TestShm(); |
| | | shm.Remove(); |
| | |
| | | } |
| | | |
| | | #if 1 |
| | | typedef AtomicQueue<3> Rcb; |
| | | typedef AtomicQueue<4> Rcb; |
| | | |
| | | Rcb tmp; |
| | | BOOST_CHECK(tmp.like_empty()); |