Push a task to the end of the queue
| 43 | |
| 44 | // Push a task to the end of the queue |
| 45 | void push(task_run_handle t) |
| 46 | { |
| 47 | // Resize queue if it is full |
| 48 | if (head == ((tail + 1) & (items.size() - 1))) { |
| 49 | detail::aligned_array<void*, LIBASYNC_CACHELINE_SIZE> new_items(items.size() * 2); |
| 50 | for (std::size_t i = 0; i != items.size(); i++) |
| 51 | new_items[i] = items[(i + head) & (items.size() - 1)]; |
| 52 | head = 0; |
| 53 | tail = items.size() - 1; |
| 54 | items = std::move(new_items); |
| 55 | } |
| 56 | |
| 57 | // Push the item |
| 58 | items[tail] = t.to_void_ptr(); |
| 59 | tail = (tail + 1) & (items.size() - 1); |
| 60 | } |
| 61 | |
| 62 | // Pop a task from the front of the queue |
| 63 | task_run_handle pop() |
no test coverage detected