[Top][All Lists]

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

Re: User interaction from multiple threads

From: Eli Zaretskii
Subject: Re: User interaction from multiple threads
Date: Thu, 30 Aug 2018 16:10:04 +0300

> From: John Shahid <address@hidden>
> Cc: Eli Zaretskii <address@hidden>, Gemini Lasswell <address@hidden>, 
> address@hidden
> Date: Wed, 29 Aug 2018 22:34:02 -0400
> > The notion of user interaction all happening on the main thread was
> > proposed earlier, and it was pointed out that it's very difficult to
> > do that, because the user interaction may involve arbitrary data which
> > is local to the originating thread.
> I thought closures would solve such a problem by encapsulating the
> context.  I imagine the main thread receiving forms from other threads
> evaluating them and returning the results back to the thread which
> becomes the value of the `(on-main-thread ...)`.  What did I miss ?

I'm afraid there's too much to encapsulate.  E.g., every buffer-local
variable in every buffer to be used by the thread will need to be
encapsulated; and how will the main thread know in advance all that?

And I think your mental model of how threads work in Emacs is
inaccurate: the main thread doesn't dispatch the other threads, in the
sense of controlling them and interacting with them.  It creates a
thread and then the thread competes for the global lock as all the
rest; once a thread grabs the lock, it basically runs disregarding the
other threads (except if the Lisp program explicitly calls APIs that
synchronize with other threads).

reply via email to

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