| 692 | thread_blocker.block_indefinite(mutex); |
| 693 | if (is_interrupted_by_signal(true)) |
| 694 | return BAN::Error::from_errno(EINTR); |
| 695 | return {}; |
| 696 | } |
| 697 | |
| 698 | BAN::ErrorOr<void> Thread::block_or_eintr_or_timeout_ns(ThreadBlocker& thread_blocker, uint64_t timeout_ns, bool etimedout, BaseMutex* mutex) |
| 699 | { |
| 700 | const uint64_t wake_time_ns = SystemTimer::get().ns_since_boot() + timeout_ns; |
| 701 | return block_or_eintr_or_waketime_ns(thread_blocker, wake_time_ns, etimedout, mutex); |
| 702 | } |
| 703 | |
| 704 | BAN::ErrorOr<void> Thread::block_or_eintr_or_waketime_ns(ThreadBlocker& thread_blocker, uint64_t wake_time_ns, bool etimedout, BaseMutex* mutex) |
| 705 | { |
| 706 | if (is_interrupted_by_signal(true)) |
| 707 | return BAN::Error::from_errno(EINTR); |
| 708 | thread_blocker.block_with_wake_time_ns(wake_time_ns, mutex); |
| 709 | if (is_interrupted_by_signal(true)) |
| 710 | return BAN::Error::from_errno(EINTR); |
| 711 | if (etimedout && SystemTimer::get().ns_since_boot() >= wake_time_ns) |
| 712 | return BAN::Error::from_errno(ETIMEDOUT); |
| 713 | return {}; |
| 714 | } |
| 715 | |
| 716 | void Thread::on_exit_trampoline(Thread* thread) |
| 717 | { |
| 718 | thread->on_exit(); |
| 719 | } |
| 720 | |
| 721 | void Thread::on_exit() |
| 722 | { |