Construct a new queue. Takes the size of backing ring buffer (must power of two and entries available will be one less than specified. default is 256), boolean where if true, queue is in single producer mode or if false, queue is in multi producer mode, boolean where if true, queue is in single consumer mode, or if false, queue is in multi consumer mode. default for both booleans is true.
| 54 | // consumer mode, or if false, queue is in multi consumer mode. default for |
| 55 | // both booleans is true. |
| 56 | LockLessQueue(size_t capacity = kDefaultRingSize, bool single_producer = true, |
| 57 | bool single_consumer = true) |
| 58 | : capacity_(capacity) { |
| 59 | CHECK((capacity & (capacity - 1)) == 0); |
| 60 | size_t ring_sz = llring_bytes_with_slots(capacity_); |
| 61 | ring_ = reinterpret_cast<struct llring*>( |
| 62 | aligned_alloc(alignof(llring), ring_sz)); |
| 63 | CHECK(ring_); |
| 64 | llring_init(ring_, capacity_, single_producer, single_consumer); |
| 65 | } |
| 66 | |
| 67 | virtual ~LockLessQueue() { |
| 68 | if (ring_) { |
nothing calls this directly
no test coverage detected