[Top][All Lists]

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

Re: [RFC] Gnus generalized search, part II

From: Eli Zaretskii
Subject: Re: [RFC] Gnus generalized search, part II
Date: Sat, 22 Apr 2017 23:06:35 +0300

> From: Eric Abrahamsen <address@hidden>
> Date: Sat, 22 Apr 2017 12:25:12 -0700
> > But what _is_ the right thing?
> >
> > I asked the question because I really would like to know what would
> > you want/expect to be the effect of C-g on the active threads?  It's
> > not a rhetoric question.  Can you please humor me?
> Okay! Sorry... Basically we're sending search queries to multiple
> servers, and using threads to make the external processes asynchronous.
> C-g would come into play when one or more of those processes hangs or is
> slow, and the user loses patience and wants to quit. The desired result
> would be that whichever thread we're currently waiting on gets killed,
> and the other threads continue.

AFAIK, this should indeed happen, at least mostly.

> Ideally there would be a message noting which search process was
> abandoned, which is another reason to use condition-case.

You mean condition-case in the thread function?

> accept-process-output is given no timeout. So when we hit the first
> `thread-join', we wait for the first accept-process-output to return
> completely, putting all its output in its process buffer. While it's
> doing that, output from the second and third thread processes is also
> arriving on the wire, but it's being buffered in C code or in the
> process itself or in some other special non-Lisp place (I'm making this
> part up, I have no idea).

Not exactly.  While the first thread waits for output, we let some
other thread run, until that other thread starts waiting as well.  The
first thread whose wait is over will become active again, because the
main thread is waiting for thread-join.  IOW, the main thread waits in
thread-join, whereas the other threads wait in accept-process-output.
I think.

> I'm trying to think about what would happen if we looped the
> `accept-process-output' on say a half-second timeout. When the first
> `thread-join' is called, does it mean all three processes would start
> getting half-second opportunities to write process output into their
> output buffers? Or would the second and third threads not get to do
> their `accept-process-output' calls at all until they were joined?

The first thread runs when the first thread-join is called by the main
thread.  The second thread gets run when the first thread calls
accept-process-output.  Etc. with the other threads.

I think there could be a problem if a thread finishes accepting its
output before its thread-join was called.

> Realistically, the user would be unlikely to quit unless one of the
> processes was taking a very long time, at which point that would be the
> only running thread, and probably the right thing would happen.

The problematic scenario is when the main thread gets the C-g.  I'm
not sure this couldn't happen in your setup.

reply via email to

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