Function: thread-join
thread-join is a function defined in thread.c.
Signature
(thread-join THREAD)
Documentation
Wait for THREAD to exit.
This blocks the current thread until THREAD exits or until the current thread is signaled. It returns the result of the THREAD function. It is an error for a thread to try to join itself.
Probably introduced at or before Emacs version 27.1.
Source Code
// Defined in /usr/src/emacs/src/thread.c
{
struct thread_state *tstate;
Lisp_Object error_symbol, error_data;
CHECK_THREAD (thread);
tstate = XTHREAD (thread);
if (tstate == current_thread)
error ("Cannot join current thread");
error_symbol = tstate->error_symbol;
error_data = tstate->error_data;
if (thread_live_p (tstate))
flush_stack_call_func (thread_join_callback, tstate);
if (!NILP (error_symbol))
Fsignal (error_symbol, error_data);
return tstate->result;
}