From: Maxime Devos <maximedevos@telenet.be>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: "guile-devel@gnu.org" <guile-devel@gnu.org>
Subject: RE: [PATCH] Make get-bytevector-all suspendable.
Date: Sun, 16 Jun 2024 15:23:55 +0200 [thread overview]
Message-ID: <20240616152355.cDPv2C00V4d9YxY01DPvdv@andre.telenet-ops.be> (raw)
In-Reply-To: <87frtddoig.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 1513 bytes --]
>> It currently is difficult to write a correct implementation of get-bytevector-all in pure Scheme, because ‘get-bytevector-all’ needs to return a _fresh_ bytevector and could return twice (e.g. in case of system-async-mark + call-with-prompt shenanigans). I think the proposed implementation is incorrect in this way.
>Hmm I don’t see how it could return twice. If an async runs while
>‘get-bytevector-all’ is executed, it cannot cause ‘get-bytevector-all’
>to abort to a prompt. I think we’re fine, no?
I did not say that ‘get-bytevector-all’ aborts to a prompt. Rather, the async itself does the abort-to-prompt, and since the async is run inside the get-bytevector-all, as a result get-bytevector-all could return twice (depending on what the handler of call-with-prompt is doing with the delimited continuation).
I’m pretty sure it can do this, that’s how Fibers works (to be clear I’m referring to the abort-to-prompt from an async, not the return twice, Fibers doesn’t do return twice things) -- non-cooperative scheduling is implemented by aborting from an async.
Example (assuming bad/good timing):
Thread #1:
;; Consider the situation where the handler invokes the delimited continuation twice.
(call-with-prompt
[tag + handler things]
(lambda () (get-bytevector-all [...]))
[tag + handler things])
Thread #2:
(system-async-mark
(lambda ()
(abort-to-prompt [tag + more arguments]))
[Thread #1]))
Best regards,
Maxime Devos.
[-- Attachment #2: Type: text/html, Size: 3162 bytes --]
next prev parent reply other threads:[~2024-06-16 13:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-20 14:01 [PATCH] Make get-bytevector-all suspendable Christopher Baines
2024-06-01 9:11 ` Ludovic Courtès
2024-06-01 9:40 ` Maxime Devos
2024-06-16 13:07 ` Ludovic Courtès
2024-06-16 13:23 ` Maxime Devos [this message]
2024-06-01 9:44 ` Maxime Devos
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=20240616152355.cDPv2C00V4d9YxY01DPvdv@andre.telenet-ops.be \
--to=maximedevos@telenet.be \
--cc=guile-devel@gnu.org \
--cc=ludo@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).