From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chris Vine Newsgroups: gmane.lisp.guile.devel,gmane.lisp.guile.user Subject: Re: anyone define port types? Date: Wed, 22 Jun 2016 23:44:50 +0100 Message-ID: <20160622234450.773f313f@bother.homenet> References: <87y492mnjp.fsf@pobox.com> <87pots9tag.fsf@gnu.org> <87bn37wtf2.fsf@pobox.com> <20160612092513.3eb1c8a3@laptop.homenet> <8760t5mthu.fsf@pobox.com> <20160619163327.36246706@dell.homenet> <8737o9kr3g.fsf@pobox.com> <20160619210912.48528ffa@dell.homenet> <20160620074503.6d06426b@dell.homenet> <87y460jou5.fsf@pobox.com> <20160620100157.530fc347@dell.homenet> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1466635527 5462 80.91.229.3 (22 Jun 2016 22:45:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 22 Jun 2016 22:45:27 +0000 (UTC) To: guile-user , guile-devel Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Jun 23 00:45:12 2016 Return-path: Envelope-to: guile-devel@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 1bFqtM-0004l2-7B for guile-devel@m.gmane.org; Thu, 23 Jun 2016 00:45:04 +0200 Original-Received: from localhost ([::1]:32998 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFqtL-0001sC-EL for guile-devel@m.gmane.org; Wed, 22 Jun 2016 18:45:03 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35676) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFqtF-0001qy-EM for guile-devel@gnu.org; Wed, 22 Jun 2016 18:44:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bFqtC-00035w-Ay for guile-devel@gnu.org; Wed, 22 Jun 2016 18:44:57 -0400 Original-Received: from smtpout4.wanadoo.co.uk ([80.12.242.68]:58629 helo=smtpout.wanadoo.co.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFqtC-00035C-1E for guile-devel@gnu.org; Wed, 22 Jun 2016 18:44:54 -0400 Original-Received: from bother.homenet ([95.146.112.124]) by mwinf5d47 with ME id 9ykr1t0032h5XBT03ykr1f; Thu, 23 Jun 2016 00:44:51 +0200 X-ME-Helo: bother.homenet X-ME-Date: Thu, 23 Jun 2016 00:44:51 +0200 X-ME-IP: 95.146.112.124 Original-Received: from bother.homenet (localhost [127.0.0.1]) by bother.homenet (Postfix) with ESMTP id E5F56126290; Wed, 22 Jun 2016 23:44:50 +0100 (BST) In-Reply-To: <20160620100157.530fc347@dell.homenet> X-Mailer: Claws Mail 3.13.1 (GTK+ 2.24.30; i686-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 80.12.242.68 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.org gmane.lisp.guile.devel:18392 gmane.lisp.guile.user:12687 Archived-At: On Mon, 20 Jun 2016 10:01:57 +0100 Chris Vine wrote: > On Mon, 20 Jun 2016 09:34:26 +0200 > Andy Wingo wrote: > [snip] > > I must not be communicating clearly because this is definitely not > > what I am proposing. The prompt doesn't service anything, and it's > > just the one user-space thread which is suspended, and when it > > suspends, it suspends back to the main loop which runs as usual, > > timers and all. > > > > prompt > > /------\ /------------\|/-----------\ /------------\ /----------\ > > | main --> run-thread -|>(user code)--> read-char --> waiter | > > | loop | | ||| | | | | | > > \------/ \------------/|\-----------/ \------------/ \--|-------/ > > ^ | > > \-------------------------------/ > > stack grows this way -> > > > > The current-read-waiter aborts to a prompt. That prompt is instated > > when the thread is run or resumed. When you abort to that prompt, > > you add the FD to the poll set / main loop / *, remember the > > delimited continuation, and return to the main loop. When the fd > > becomes readable or the gsource fires or whatever, you reinstate the > > delimited continuation via a new invocation of run-thread (prompt > > and all). > > Ah right, that is clearer, thank you. There would indeed be a prompt > for each user glib event source comprised in the "thread" abstraction, > which the read-waiter (or whatever) aborts to. It is that abstraction > that I was missing and will need to look at. I have stirred myself and installed guile-2.1.3. On looking more at the suspendable ports code it became obvious and I haven't needed to adopt anything like ethreads with its "thread" abstraction: instead I have kept the approach already adopted in the guile-a-sync library. However, the consequence of using suspendable ports instead of C ports is that the await-getline! procedure (as an example) has been reduced to a mere 16 lines of code, mainly because it is possible to use (ice-9 rdelim)'s read-line procedure with non-blocking ports. I have made a new repository for guile-a-sync for use with guile-2.2 and when I am happy with the new interfaces (and assuming nothing else goes wrong) I will put it up on github. This is very nice. Thanks for taking the time to go through it with me. Chris