From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: [RFC] Gnus generalized search, part II Date: Sat, 22 Apr 2017 23:06:35 +0300 Message-ID: <83shl0p5pw.fsf@gnu.org> References: <87zif930mt.fsf@ericabrahamsen.net> <87tw5hjnzr.fsf@hanan> <87mvb92er2.fsf@ericabrahamsen.net> <83efwkrhj1.fsf@gnu.org> <87inlw32ga.fsf@ericabrahamsen.net> <8337d0qxno.fsf@gnu.org> <87shl01bzb.fsf@ericabrahamsen.net> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1492891618 5810 195.159.176.226 (22 Apr 2017 20:06:58 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 22 Apr 2017 20:06:58 +0000 (UTC) Cc: emacs-devel@gnu.org To: Eric Abrahamsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Apr 22 22:06:54 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d21Iz-0001PK-6I for ged-emacs-devel@m.gmane.org; Sat, 22 Apr 2017 22:06:53 +0200 Original-Received: from localhost ([::1]:36719 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d21J5-0007ug-0a for ged-emacs-devel@m.gmane.org; Sat, 22 Apr 2017 16:06:59 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58692) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d21ID-0007t3-1M for emacs-devel@gnu.org; Sat, 22 Apr 2017 16:06:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d21I9-0006u2-Qv for emacs-devel@gnu.org; Sat, 22 Apr 2017 16:06:05 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:54258) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d21I9-0006ty-NR; Sat, 22 Apr 2017 16:06:01 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4414 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1d21I7-00086i-D4; Sat, 22 Apr 2017 16:06:01 -0400 In-reply-to: <87shl01bzb.fsf@ericabrahamsen.net> (message from Eric Abrahamsen on Sat, 22 Apr 2017 12:25:12 -0700) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:214226 Archived-At: > From: Eric Abrahamsen > 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.