Hello,
I don't find a solution how to suspend a gambit thread until input is available (and/or output is possible) on a file descriptor with known number, which is opened in non-blocking mode by a foreign library. Is there a clean way without polling?
Regards Hermann
Afficher les réponses par date
Hello,
I don't find a solution how to suspend a gambit thread until input is available (and/or output is possible) on a file descriptor with known number, which is opened in non-blocking mode by a foreign library. Is there a clean way without polling?
You could create a Scheme port from the file descriptor and then use the normal I/O operations on that. Here is some (untested) code to illustrate how this can be done:
(define direction-in 1) (define direction-out 2) (define direction-inout 3)
(define (fd->port fd mode) (##open-predefined mode '(fd-port) fd))
(define fd (get-fd-using-ffi!))
(define my-port (fd->port fd direction-inout))
... use my-port like a normal port ...
Marc