| 551 | size_t tail = 0; // events[tail] is not finished |
| 552 | |
| 553 | void rotate() { |
| 554 | while (tail < head && events[tail % bucket_count]->finished()) { |
| 555 | ++tail; |
| 556 | } |
| 557 | auto& ev = events[head % bucket_count]; |
| 558 | if (head == tail + bucket_count) { |
| 559 | // do not wait if head == tail |
| 560 | ev->host_wait(); |
| 561 | ++tail; |
| 562 | } |
| 563 | ev->record(); |
| 564 | ++head; |
| 565 | free_slots = bucket_size; |
| 566 | } |
| 567 | |
| 568 | public: |
| 569 | CompNodeTracker(CompNode cn) : comp_node(cn) { |