* Waiting for all current vcpu photon threads finish * @return 0 for all done, -1 for failure */
| 2037 | * @return 0 for all done, -1 for failure |
| 2038 | */ |
| 2039 | static int wait_all(RunQ rq, vcpu_t* vcpu) { |
| 2040 | auto &sleepq = vcpu->sleepq; |
| 2041 | auto &standbyq = vcpu->standbyq; |
| 2042 | while (!AtomicRunQ(rq).size_1or2() || !sleepq.empty() || !standbyq.empty()) { |
| 2043 | if (!sleepq.empty()) { |
| 2044 | // sleep till all sleeping threads ends |
| 2045 | thread_usleep(1000UL); |
| 2046 | } else { |
| 2047 | thread_yield(); |
| 2048 | } |
| 2049 | } |
| 2050 | return 0; |
| 2051 | } |
| 2052 | |
| 2053 | int wait_all() { |
| 2054 | RunQ rq; |