From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Newsgroups: gmane.lisp.guile.user Subject: Re: The equivalent of racket's break-thread in guile? Date: Sun, 02 Jun 2013 15:51:31 +0200 Message-ID: <87vc5wtycc.fsf@gnu.org> References: <871u8ncvsn.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1370181118 27120 80.91.229.3 (2 Jun 2013 13:51:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 2 Jun 2013 13:51:58 +0000 (UTC) Cc: guile-user@gnu.org To: Xin Wang Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Jun 02 15:51:59 2013 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Uj8hS-0002ey-FS for guile-user@m.gmane.org; Sun, 02 Jun 2013 15:51:58 +0200 Original-Received: from localhost ([::1]:39043 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uj8hR-0000Jw-QJ for guile-user@m.gmane.org; Sun, 02 Jun 2013 09:51:57 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43894) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uj8hF-0000JD-Mc for guile-user@gnu.org; Sun, 02 Jun 2013 09:51:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uj8hE-0005Xl-K0 for guile-user@gnu.org; Sun, 02 Jun 2013 09:51:45 -0400 Original-Received: from hera.aquilenet.fr ([141.255.128.1]:37593) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uj8hE-0005Xb-EN for guile-user@gnu.org; Sun, 02 Jun 2013 09:51:44 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id AE2F1A94; Sun, 2 Jun 2013 15:51:32 +0200 (CEST) Original-Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EBUkUa2FtT2X; Sun, 2 Jun 2013 15:51:32 +0200 (CEST) Original-Received: from pluto (reverse-83.fdn.fr [80.67.176.83]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 2198CA66; Sun, 2 Jun 2013 15:51:32 +0200 (CEST) X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 14 Prairial an 221 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu In-Reply-To: (Xin Wang's message of "Sun, 2 Jun 2013 07:49:01 +0800") User-Agent: Gnus/5.130007 (Ma Gnus v0.7) Emacs/24.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-Received-From: 141.255.128.1 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:10404 Archived-At: Xin Wang skribis: > 2013/5/31 Ludovic Court=C3=A8s > >> Xin Wang skribis: >> >> > In Guile, the equivalent of kill-thread is cancel-thread, and is there >> any >> > equivalent of break-thread? >> > >> > [1] http://docs.racket-lang.org/reference/breakhandler.html >> >> If I understand correctly, =E2=80=9Cbreaks=E2=80=9D are similar to Guile= =E2=80=99s =E2=80=9Casyncs=E2=80=9D >> (info "(guile) Asyncs"). >> >> However, I don=E2=80=99t understand what you=E2=80=99re trying to achiev= e. Could you >> give another example of the behavior you=E2=80=99re after? >> >> > I was reading source code of Arc language[1], and wondering if it is > possible to port it to Guile. > > It define a function to handle HTTP request in srv.arc(L48): > > (def handle-request-1 (s) > --- pruned --- > (with (th1 nil th2 nil) > (=3D th1 (thread > (after (handle-request-thread i o ip) > (close i o) > (kill-thread th2)))) > (=3D th2 (thread > (sleep threadlife*) > (unless (dead th1) > (prn "srv thread took too long for " ip)) > (break-thread th1) > (force-close i o)))))))) > > It create two threads to handle a request, one do main stuff and anthor o= ne > wait to kill first one if it takes too much time. Here =E2=80=98break-thread=E2=80=99 in the first thread appears to be equiv= alent to Guile=E2=80=99s =E2=80=98cancel-thread=E2=80=99. > Although I'm not quite sure, I think one reason to use 'kill-thread' and > 'break-thread' differently is to make sure that exception handler function > is fully executed. ('after' is implemented by dynamic-wind). Hmm, I guess I still don=E2=80=99t understand what =E2=80=98break-thread=E2= =80=99 is supposed to do. Ludo=E2=80=99.