unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* [PATCH] Add current-suspendable-io-status parameter
@ 2019-05-13 10:54 Nala Ginrut
  2019-05-13 10:56 ` Nala Ginrut
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Nala Ginrut @ 2019-05-13 10:54 UTC (permalink / raw)
  To: guile-devel

[-- 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


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2019-05-18 23:06 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-13 10:54 [PATCH] Add current-suspendable-io-status parameter Nala Ginrut
2019-05-13 10:56 ` 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

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).