From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nala Ginrut Newsgroups: gmane.lisp.guile.user Subject: Re: The equivalent of racket's break-thread in guile? Date: Fri, 31 May 2013 11:59:57 +0800 Organization: HFG Message-ID: <1369972797.2610.57.camel@Renee-desktop.suse> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1369972817 6978 80.91.229.3 (31 May 2013 04:00:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 31 May 2013 04:00:17 +0000 (UTC) Cc: guile-user@gnu.org To: Xin Wang Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Fri May 31 06:00:18 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 1UiGVl-0001Xo-OY for guile-user@m.gmane.org; Fri, 31 May 2013 06:00:17 +0200 Original-Received: from localhost ([::1]:60572 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiGVl-0004Eq-Dg for guile-user@m.gmane.org; Fri, 31 May 2013 00:00:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47339) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiGVc-0004Da-VI for guile-user@gnu.org; Fri, 31 May 2013 00:00:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UiGVa-0006Y1-ON for guile-user@gnu.org; Fri, 31 May 2013 00:00:08 -0400 Original-Received: from mail-pb0-x229.google.com ([2607:f8b0:400e:c01::229]:32794) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiGVa-0006XH-IQ for guile-user@gnu.org; Fri, 31 May 2013 00:00:06 -0400 Original-Received: by mail-pb0-f41.google.com with SMTP id xb12so1517970pbc.28 for ; Thu, 30 May 2013 21:00:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:subject:from:to:cc:date:in-reply-to:references :organization:content-type:x-mailer:mime-version :content-transfer-encoding; bh=gftePZ0gQcqWbG2QeGw9BbK0n5T2OZuQ2N9aZ1dWUxs=; b=yhhvrCVxfziejBNyQgVGVBUKqRnSeO5HzuU1p0a04KgnzwHpbnmRzSgRiW0bqS9HFt ZcKhcb5F/4qZZIAX3mERsdTXBsZwGJoHbGBVW9X/VQhZ6RWOw+v5ejkmRGupWsZiyK8+ 70yDPj/rn6ziTOv//IaN5H923qMDhCmg77yXRzottSuzKINRoLwjXABsWh8J5RTyzhmg bB4V6uIQyi/8wQCfzue2E3lEJ75QWwp90FaEiZTEICE8ocOvSt1JfT/9yOsbN8pqPmRm gmMYZz0DScbpE3lgP3DnbwTpMlcYchWHH5a+KlMm+SOfZvjDj0pjjlT+AUFy7HQitrWW AtQw== X-Received: by 10.68.99.163 with SMTP id er3mr11211671pbb.36.1369972805411; Thu, 30 May 2013 21:00:05 -0700 (PDT) Original-Received: from [147.2.147.115] ([61.14.130.226]) by mx.google.com with ESMTPSA id sg4sm44748495pbc.7.2013.05.30.21.00.01 for (version=SSLv3 cipher=RC4-SHA bits=128/128); Thu, 30 May 2013 21:00:04 -0700 (PDT) In-Reply-To: X-Mailer: Evolution 3.4.4 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c01::229 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:10389 Archived-At: On Fri, 2013-05-31 at 07:40 +0800, Xin Wang wrote: > In Racket, break-thread is used to send an break exception to a thread[1]. > > E. g. > > (let ((th (thread (lambda () > (dynamic-wind > (lambda () #t) > (lambda () (/ 1 0)) > (lambda () (sleep 5) (display "out-guard\n"))))))) > > (sleep 1) > (break-thread th)) > > For above code, out-guard part of dynmaic-wind will not be interrupted if > use break-thread to cancel a thread, and kill-thread will cancel thread > immediately. > > 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 > I think the answer is NO. The thread in Racket is green-thread which is implemented by some kind of stack-copying. That's why its thread could receive the so-called 'break signal'. The scheduler is in the VM rather than OS. But the traditional thread in Guile is based on pthread. So they are very different. Anyway, I'm trying to write green-thread based on delimited-continuation which will be used for an Actor-model implementation. > Regards, > Xin Wang