[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: Mon, 20 Aug 2018 20:07:23 +0300

> From: Gemini Lasswell <address@hidden>
> Cc: Eli Zaretskii <address@hidden>,  Emacs-devel <address@hidden>,  
> address@hidden
> Date: Mon, 20 Aug 2018 07:15:05 -0700
> Is it guaranteed that the thread scheduler will allow all other
> ready threads a turn to execute during the main thread's
> thread-yield?

No.  The "scheduler" we have is actually a race to grab the global
lock; the first thread to succeed starts running, the others wait.

> If not, maybe a good-enough-most-of-the-time solution would be for the
> main thread to do a sleep-for for an amount of time that won't bother
> the user, like 0.1s, and if the most-recent thread hasn't added a prompt
> to the queue by then, then go on to the next thread's prompt.

When the main thread calls sleep-for, it enters the "scheduler", so
some other thread will start running, and there's no guarantee that
the main thread will resume after 0.1 sec: it might be much later, if
that other thread has something to do that takes a long time.

reply via email to

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