compare m_nodes[idx] with child node.
| 454 | |
| 455 | // compare m_nodes[idx] with child node. |
| 456 | bool down(int idx) |
| 457 | { |
| 458 | assert(!q.empty()); |
| 459 | auto tmp = q[idx]; |
| 460 | size_t cmpIdx = (idx << 1) + 1; |
| 461 | bool ret = false; |
| 462 | while (cmpIdx < q.size()) { |
| 463 | if (cmpIdx + 1 < q.size() && *q[cmpIdx + 1] < *q[cmpIdx]) cmpIdx++; |
| 464 | if (*q[cmpIdx] < *tmp){ |
| 465 | update_node(idx, q[cmpIdx]); |
| 466 | idx = cmpIdx; |
| 467 | cmpIdx = (idx << 1) + 1; |
| 468 | ret = true; |
| 469 | continue; |
| 470 | } |
| 471 | break; |
| 472 | } |
| 473 | if (ret) update_node(idx, tmp); |
| 474 | return ret; |
| 475 | } |
| 476 | }; |
| 477 | |
| 478 | // A special spinlock that distinguishes a foreground vCPU among |