|
From: | yyoncho |
Subject: | Re: Questions about throw-on-input |
Date: | Fri, 8 May 2020 14:55:16 +0300 |
> From: Ivan Yonchovski <address@hidden>
> Cc: address@hidden
> Date: Fri, 08 May 2020 14:23:34 +0300
>
> (defun process-events ()
> (when (input-pending-p)
> (run-with-timer 0.01 nil (lambda () (throw 'exit nil)))
> (recursive-edit)))
>
> (dotimes (counter 1000)
> (sleep-for 0.01) ;; simulate execution of N tasks
> (message "%s" counter)
> (process-events))
>
> This code is able to handle C-n but obviously it will break if someone
> starts another recursive-edit or for complex keybindings, e. g. `C-x b`.
I think you will indeed find that this is very fragile.
> Are you aware of something doing something similar? Do you think it
> makes sense if you want to process something slow on the background
> without blocking emacs?
I think this is why we added threads to Emacs. Why not try doing this
in a thread?
> > AFAIU, such facilities need to have a separate event loop that
> > generally runs in a separate thread.
>
> In the C# case it all happens on the UI thread. DoEvents means handle
> mouse clicks, repaint controls, etc(the stuff from the event loop) and
> then continue with current execution.
When display is as intimately connected to the global state as it is
in Emacs, I don't think such separation can fly.
[Prev in Thread] | Current Thread | [Next in Thread] |