From ab1f9def674a19a4befaa310a502f4d08ddc7363 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Mon, 11 Sep 2023 12:09:32 +0100 Subject: [PATCH] io-wakeup: Use file descriptors when calling select. Rather than ports, since select doesn't work for all ports in Guile. * fibers/io-wakeup.scm (readable?, writable?, try-ready): Take a fd rather than a port. (wait-until-port-readable-operation, wait-until-port-writable-operation): Pass the fd to try-ready?. --- fibers/io-wakeup.scm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fibers/io-wakeup.scm b/fibers/io-wakeup.scm index 188d83e..4ae55ae 100644 --- a/fibers/io-wakeup.scm +++ b/fibers/io-wakeup.scm @@ -51,21 +51,21 @@ ;; These procedure are subject to spurious wakeups. -(define (readable? port) +(define (readable? fd) "Test if PORT is writable." - (match (select (vector port) #() #() 0) + (match (select (vector fd) #() #() 0) ((#() #() #()) #f) ((#(_) #() #()) #t))) -(define (writable? port) +(define (writable? fd) "Test if PORT is writable." - (match (select #() (vector port) #() 0) + (match (select #() (vector fd) #() 0) ((#() #() #()) #f) ((#() #(_) #()) #t))) -(define (try-ready ready? port) +(define (try-ready ready? fd) (lambda () - (and (ready? port) values))) + (and (ready? fd) values))) (define (make-wait-operation try-fn schedule-when-ready port port-ready-fd) (letrec ((this-operation @@ -110,11 +110,11 @@ of the operation." (define (wait-until-port-readable-operation port) "Make an operation that will succeed when PORT is readable." - (make-read-operation (try-ready readable? port) port)) + (make-read-operation (try-ready readable? (port-read-wait-fd port)) port)) (define (wait-until-port-writable-operation port) "Make an operation that will succeed when PORT is writable." - (make-write-operation (try-ready readable? port) port)) + (make-write-operation (try-ready readable? (port-write-wait-fd port)) port)) (define (with-x-waiting-is-failure port current-x-waiter try-fn) "Return a thunk like TRY-FN, except that it also fails when