From: Chris Vine <vine24683579@gmail.com>
To: guile-user@gnu.org
Subject: Re: Question about an error with ports
Date: Fri, 11 Mar 2022 17:26:50 +0000 [thread overview]
Message-ID: <20220311172650.aeab7bf504b38992196e0141@gmail.com> (raw)
In-Reply-To: <87czisbkng.fsf@laura>
On Fri, 11 Mar 2022 09:58:59 -0500
Olivier Dion <olivier.dion@polymtl.ca> wrote:
> On Fri, 11 Mar 2022, Chris Vine <vine24683579@gmail.com> wrote:
[snip]
> > Avoid using get-bytevector-n!, get-bytevector-some and
> > get-bytevector-all if you are going to use something like fibers or
> > some other asynchronous i/o, as those procedures are not suspendable
> > (they can block). get-bytevector-n (note the difference from
> > get-bytevector-n!) and get-string-all are suspendable and should
> > generally be preferred where suspension is required.
>
> I'm not sure this is related to the functions themself but instead the
> underlying filedescriptor opened iwth ON_NONBLOCK?
The problem I am referring to is different: it is that delimited
continuations cannot capture C code and ports are written in C.
Suspendable specializations, written in pure scheme, of some of guile's
i/o procedures are therefore provided in
modules/ice-9/suspendable-ports.scm, which is a file worth reading on
its own account, and which are brought into effect (by suppressing the
C-based equivalents) by applying the install-suspendable-ports!
procedure. If your i/o steps out of this set of primitives (see in
particular the port-bindings variable in that file) then it is not
suspendable.
When suspendable ports were first introduced in guile-2.2.0, this
safe set did not include get-bytevector-n!, get-bytevector-some,
get-bytevector-some! and get-bytevector-all: I have just re-read the
code in guile-2.2.0 to confirm this. I have also just checked with the
latest versions of guile-2.2 and guile-3.0 and it appears that
get-bytevector-n!, get-bytevector-some and get-bytevector-some! are now
supported so it looks as if at some point since version 2.2.0 they have
become OK.
With guile-2.2.0, this in turn meant that amongst other things,
http-get, http-put and so on could not normally be used in suspendable
code. I would need to check whether that remains the case - I cannot
now remember which calls they made which were forbidden to suspendable
code.
Notable procedures which it appears remain as non-suspendable are
get-bytevector-all, get-string-n, read, write and display, but to be
sure about the first two of those I would also need to read the source
again. A few years ago I had some test code to test which procedures
were suspendable and I will also have to see if I can find it again.
Chris
next prev parent reply other threads:[~2022-03-11 17:26 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-10 1:26 Question about an error with ports Zelphir Kaltstahl
2022-03-10 15:05 ` Olivier Dion via General Guile related discussions
2022-03-10 22:32 ` Zelphir Kaltstahl
2022-03-10 23:46 ` Olivier Dion via General Guile related discussions
2022-03-11 12:05 ` Chris Vine
2022-03-11 14:58 ` Olivier Dion via General Guile related discussions
2022-03-11 17:26 ` Chris Vine [this message]
2022-03-11 17:47 ` Olivier Dion via General Guile related discussions
2022-03-11 18:13 ` Chris Vine
2022-03-11 19:48 ` Maxime Devos
2022-03-11 19:49 ` Maxime Devos
2022-03-12 0:10 ` Chris Vine
2022-03-12 0:27 ` Chris Vine
2022-03-11 12:11 ` Maxime Devos
2022-03-11 15:06 ` Olivier Dion via General Guile related discussions
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220311172650.aeab7bf504b38992196e0141@gmail.com \
--to=vine24683579@gmail.com \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).