Allowing condition-notify call from non-elisp threads would solve the problem as well. 

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=42028 

On Sat, Oct 31, 2020 at 9:46 AM Eli Zaretskii <eliz@gnu.org> wrote:
> From: Zhu Zihao <all_but_last@163.com>
> Date: Sat, 31 Oct 2020 11:18:43 +0800
> Cc: emacs-devel@gnu.org
>
> What about callbacks? You can pass a Lisp closure to module and call the
> closure from module.

How will this work, if the callback is called asynchronously?  The
Lisp interpreter cannot be reentered.

I think the method described by Stefan is the only sane path towards
solving these situations.  It uses the infrastructure Emacs itself
uses for asynchronous interactions.