From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.user,gmane.lisp.guile.devel Subject: Re: anyone define port types? Date: Mon, 20 Jun 2016 09:34:26 +0200 Message-ID: <87y460jou5.fsf@pobox.com> 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> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1466408144 22641 80.91.229.3 (20 Jun 2016 07:35:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 20 Jun 2016 07:35:44 +0000 (UTC) Cc: guile-user , guile-devel To: Chris Vine Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Jun 20 09:35:36 2016 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 1bEtk7-0005zd-Iu for guile-user@m.gmane.org; Mon, 20 Jun 2016 09:35:35 +0200 Original-Received: from localhost ([::1]:41798 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEtk6-0004HC-JY for guile-user@m.gmane.org; Mon, 20 Jun 2016 03:35:34 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59102) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEtjJ-0004E5-LR for guile-user@gnu.org; Mon, 20 Jun 2016 03:34:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bEtjH-00017U-AT for guile-user@gnu.org; Mon, 20 Jun 2016 03:34:44 -0400 Original-Received: from pb-sasl1.pobox.com ([64.147.108.66]:57362 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEtjB-00016C-LQ; Mon, 20 Jun 2016 03:34:37 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-sasl1.pobox.com (Postfix) with ESMTP id 92D811DF2B; Mon, 20 Jun 2016 03:34:35 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=AoLUtBuHIyPIZTOm6HoEik7tvCA=; b=IgPwu6 WyFolDp/Q3xB9PLZS/VZlJ4tiaR0RFhNGgeyMhqT06s0B4DhkMBBh1HUqXjPPf/o ldjagMF+2aDG6cXv6SSK0ZfVEqcfTB8QhUSHqDh3YNhakD1hxtw4IAbh2bNfzHTo VbiPeAO83CnJ68qM1d3k7A/vCLXEi1HcIa/II= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=dGbfnCVPkr2+89cbkMfAswMyIUQcBPph aHjtYnMj6+gOFGCje4m71oK8d95ZXtwUWxbFG/iByLwZDq8NNXWhlipR7O+Mi0z0 howKlT2CEpSXj/S7TXuEpqQllpfCxtmCYid1OtC/JHP9U4pNgP9FTyO5KwCWLQyN homeBkxVm6c= Original-Received: from pb-sasl1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-sasl1.pobox.com (Postfix) with ESMTP id 89E701DF2A; Mon, 20 Jun 2016 03:34:35 -0400 (EDT) Original-Received: from clucks (unknown [88.160.190.192]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by pb-sasl1.pobox.com (Postfix) with ESMTPSA id A5A7E1DF29; Mon, 20 Jun 2016 03:34:34 -0400 (EDT) In-Reply-To: <20160620074503.6d06426b@dell.homenet> (Chris Vine's message of "Mon, 20 Jun 2016 07:45:03 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-Pobox-Relay-ID: 6F8BFCD0-36B9-11E6-928A-C1836462E9F6-02397024!pb-sasl1.pobox.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.108.66 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.lisp.guile.user:12659 gmane.lisp.guile.devel:18356 Archived-At: On Mon 20 Jun 2016 08:45, Chris Vine writes: > For simplicity, let's say you have a file watch in the glib event loop > which has made a non-blocking read of the first byte of a multi-byte > UTF-8 character, and the suspendable-ports implementation is in use > because it is a non-blocking read of a TCP socket. (It could be > something different: there may be a non-blocking read request for a > complete line of text which has so far only partially been satisfied, > but the partially complete character is the easiest example to deal > with.) The read request is therefore in read-waiter waiting for a > complete UTF-8 byte sequence to arrive. On the current hypothesis, > read-waiter comprises a procedure which is suspended on a prompt > waiting for an event to occur in the glib main loop which will cause > it to resume, comprising the file descriptor becoming ready which will > satisfy the read request. But while suspended in read-waiter, this > prompt would have to service any user event sources which might become > ready in the glib main loop, not just the particular file descriptor > in question becoming ready. 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). > My approach on the other hand does not nest events from the glib main > loop in this way. "Nesting events" should not be a thing you have to do. Andy