[gambit-list] FFI & threads

Hermann Jurksch JURKSCH at focus.ping.de
Wed Nov 3 18:42:00 EST 2004


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

Thanks, this solves one part of the problem. But the
scheme code must not read or write any byte from/to my-port.
And I don't see a way to implement
(if (foreign-function-tells-io-would-block)
    (suspend-me-until-io-will-not-block))
without reading or writing.

Regards
        Hermann


P.S.: Is ##open-predefined considered stable?


More information about the Gambit-list mailing list