[Top][All Lists]

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

Re: Is automatic yield support feasible for threads?

From: ndame
Subject: Re: Is automatic yield support feasible for threads?
Date: Wed, 10 Nov 2021 07:46:48 +0000

On Tuesday, November 9th, 2021 at 3:53 PM, Philipp <> 
> I don't think it's feasible. Emacs Lisp code typically relies heavily on 
> mutating global state (think buffer contents, the buffer list, `point', 
> dynamic variables, ...), and normally doesn't put such state mutations into 
> properly synchronized critical sections. Yielding from such unprotected 
> critical sections would result in very subtle bugs (`point' randomly moving 
> around, corruption of internal data structures, buffers vanishing 
> surprisingly, ...).

I don't think threads should be used for UI manipulation, that should be left 
for the main thread. Threads are more useful for longer running calculations, 
computations and those should have no problem if they work on local data.

But you are right if someone uses a thread for UI changes then there can be 
problems. My idea is about an _optional_ automatic yielding for threads, so it 
still could be useful for those threads which are self contained. Those could 
choose to start with periodic automatic yielding, so their code do not have to 
be sprinkled with manual yield calls, impacting code readability.

reply via email to

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