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: Mon, 03 Jun 2013 12:12:56 +0200 Message-ID: <8738szh593.fsf@gnu.org> References: <871u8ncvsn.fsf@gnu.org> <87vc5wtycc.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 1370254698 9804 80.91.229.3 (3 Jun 2013 10:18:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 3 Jun 2013 10:18:18 +0000 (UTC) Cc: Guile User To: Xin Wang Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Jun 03 12:18:19 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 1UjRqF-00058Z-69 for guile-user@m.gmane.org; Mon, 03 Jun 2013 12:18:19 +0200 Original-Received: from localhost ([::1]:60570 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjRqE-0000zo-Ko for guile-user@m.gmane.org; Mon, 03 Jun 2013 06:18:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48015) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjRq3-0000yO-C4 for guile-user@gnu.org; Mon, 03 Jun 2013 06:18:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UjRq1-00024e-TO for guile-user@gnu.org; Mon, 03 Jun 2013 06:18:07 -0400 Original-Received: from hera.aquilenet.fr ([141.255.128.1]:39661) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjRq1-00024V-N0 for guile-user@gnu.org; Mon, 03 Jun 2013 06:18:05 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 2BC60AF6; Mon, 3 Jun 2013 12:13:04 +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 ng4x8ntxgG3B; Mon, 3 Jun 2013 12:13:04 +0200 (CEST) Original-Received: from pluto (195.Red-88-5-174.dynamicIP.rima-tde.net [88.5.174.195]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 90A2B576; Mon, 3 Jun 2013 12:13:02 +0200 (CEST) X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 15 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 "Mon, 3 Jun 2013 09:37:45 +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:10406 Archived-At: Xin Wang skribis: > 2013/6/2 Ludovic Court=C3=A8s > >> 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 th= ere >> >> 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 Gu= ile=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 ach= ieve. 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 >> one >> > 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 eq= uivalent to >> Guile=E2=80=99s =E2=80=98cancel-thread=E2=80=99. >> > > Do you mean 'kill-thread' in the first thread? Oh, yes, sorry for the confusion! Ludo=E2=80=99.