help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Is automatic yield support feasible for threads?


From: ndame
Subject: Is automatic yield support feasible for threads?
Date: Thu, 04 Nov 2021 17:10:05 +0000

AFAIK Emacs has cooperative threading, so a badly behaving thread can prevent 
UI updates, therefore if some costly operation is moved into a separate thread 
then the code has to be modified in order to yield periodically if the code 
doesn't do I/O.

If that's the case then what if the interpreter itself could support automatic 
yielding when some flag is set, so it could yield automatically after every 
several instructions?

For example, make-thread could have an optional argument specifying after how 
many instructions a thread-yield should be called automatically and if this 
argument is set then a global flag is set, so the interpreter knowns it should 
call yield regularly.

This automatic yielding would have some cost, but in return any code could 
safely be moved into a separate thread without the danger of locking up the UI 
if this optional argument is given to make-thread. So it could makes using 
cooperative threads easier.

Could such an automatic yield support be feasible for threads?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]