| 1528 | } |
| 1529 | |
| 1530 | void* thread_join(join_handle* jh) { |
| 1531 | auto th = (thread*)jh; |
| 1532 | assert(th->is_joinable()); |
| 1533 | if (!th->is_joinable()) |
| 1534 | LOG_ERROR_RETURN(ENOSYS, nullptr, "join is not enabled for thread ", th); |
| 1535 | |
| 1536 | th->lock.lock(); |
| 1537 | while (th->state != states::DONE) { |
| 1538 | th->cond.wait(th->lock); |
| 1539 | } |
| 1540 | auto retval = th->retval; |
| 1541 | th->dispose(); |
| 1542 | return retval; |
| 1543 | } |
| 1544 | inline void thread_join(thread* th) |
| 1545 | { |
| 1546 | thread_join((join_handle*)th); |