From: Nala Ginrut <nalaginrut@gmail.com>
To: guile-devel <guile-devel@gnu.org>
Subject: [PATCH] Add current-suspendable-io-status parameter
Date: Mon, 13 May 2019 18:54:38 +0800 [thread overview]
Message-ID: <CAPjoZod52bSS4=Fxsu1Fe6sfENsHVFByyW6bGsciwV_ngtWnyA@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 395 bytes --]
Hi folks!
Here's a patch to add current-suspendable-io-status:
Its result is a pair: (finished-bytes . rest-bytes)
This is useful for designing a proper scheduler algorithm for
suspendable I/O operations.
For example, the server-core based on delimited-continuation can
compute a priority based on this status to decide how to schedule the
suspended task.
Comments are welcome.
Best regards.
[-- Attachment #2: 0001-Add-current-suspendable-io-status.patch --]
[-- Type: text/x-patch, Size: 1970 bytes --]
From 59c2584a1eda94c19fbef07bb8bfa36da3c0ce1c Mon Sep 17 00:00:00 2001
From: Nala Ginrut <mulei@gnu.org>
Date: Mon, 13 May 2019 18:45:54 +0800
Subject: [PATCH] Add current-suspendable-io-status
When suspendable-port is blocking, the IO waiter function can get the status
of the current IO operation.
(current-suspendable-io-status) returns a pair: (finished-bytes . rest-bytes)
---
module/ice-9/suspendable-ports.scm | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/module/ice-9/suspendable-ports.scm b/module/ice-9/suspendable-ports.scm
index a366c8b9c..33d307a2c 100644
--- a/module/ice-9/suspendable-ports.scm
+++ b/module/ice-9/suspendable-ports.scm
@@ -54,6 +54,7 @@
#:use-module (ice-9 match)
#:export (current-read-waiter
current-write-waiter
+ current-suspendable-io-status
install-suspendable-ports!
uninstall-suspendable-ports!))
@@ -63,6 +64,7 @@
(define current-read-waiter (make-parameter default-read-waiter))
(define current-write-waiter (make-parameter default-write-waiter))
+(define current-suspendable-io-status (make-parameter (cons 0 0)))
(define (wait-for-readable port) ((current-read-waiter) port))
(define (wait-for-writable port) ((current-write-waiter) port))
@@ -75,7 +77,8 @@
(error "bad return from port read function" read))
read))
(else
- (wait-for-readable port)
+ (parameterize ((current-suspendable-io-status (cons start count)))
+ (wait-for-readable port))
(read-bytes port dst start count))))
(define (write-bytes port src start count)
@@ -87,7 +90,8 @@
(when (< written count)
(write-bytes port src (+ start written) (- count written)))))
(else
- (wait-for-writable port)
+ (parameterize ((current-suspendable-io-status (cons start count)))
+ (wait-for-writable port))
(write-bytes port src start count))))
(define (flush-input port)
--
2.20.1
next reply other threads:[~2019-05-13 10:54 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-13 10:54 Nala Ginrut [this message]
2019-05-13 10:56 ` [PATCH] Add current-suspendable-io-status parameter Nala Ginrut
2019-05-13 20:54 ` Mark H Weaver
2019-05-13 23:00 ` Mark H Weaver
2019-05-14 4:22 ` Nala Ginrut
2019-05-14 20:22 ` Mark H Weaver
2019-05-15 9:31 ` Nala Ginrut
2019-05-16 0:58 ` Mark H Weaver
2019-05-17 11:07 ` Nala Ginrut
2019-05-18 23:06 ` Mark H Weaver
2019-05-15 10:09 ` tomas
2019-05-15 11:25 ` Chris Vine
2019-05-15 12:08 ` tomas
2019-05-15 11:25 ` Nala Ginrut
2019-05-15 12:10 ` tomas
2019-05-15 12:26 ` Nala Ginrut
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='CAPjoZod52bSS4=Fxsu1Fe6sfENsHVFByyW6bGsciwV_ngtWnyA@mail.gmail.com' \
--to=nalaginrut@gmail.com \
--cc=guile-devel@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).