| 36 | namespace storage { |
| 37 | |
| 38 | bool EvictionQueue::insert(uint32_t fileIndex, page_idx_t pageIndex) { |
| 39 | EvictionCandidate candidate{fileIndex, pageIndex}; |
| 40 | while (size < capacity) { |
| 41 | // Weak is fine since spurious failure is acceptable. |
| 42 | // The slot can always be filled later. |
| 43 | auto emptyCandidate = EMPTY; |
| 44 | if (data[insertCursor.fetch_add(1, std::memory_order_relaxed) % capacity] |
| 45 | .compare_exchange_weak(emptyCandidate, candidate)) { |
| 46 | size++; |
| 47 | return true; |
| 48 | } |
| 49 | } |
| 50 | return false; |
| 51 | } |
| 52 | |
| 53 | std::span<std::atomic<EvictionCandidate>, EvictionQueue::BATCH_SIZE> EvictionQueue::next() { |
| 54 | return std::span<std::atomic<EvictionCandidate>, BATCH_SIZE>( |
no outgoing calls
no test coverage detected