[gambit-list] Is long poll for activity on external file descriptors without Gambit reading data currently doable, and if so, how?
Christian Jaeger
christian at pflanze.mine.nu
Wed Sep 3 13:38:34 EDT 2008
Marc Feeley wrote:
> On 2-Sep-08, at 8:04 PM, Christian Jaeger wrote:
>
>
>> Wait, I think I get what you want: you want to block your Gambit
>> thread
>> just as in a read or write operation but not actually carry out any
>> read
>> or write, correct? Just kind of peek-char that doesn't read into a
>> buffer etc.; or basically, you want that this blocks until there is
>> data
>> to be read or there is the possibility to write data (pardon my shell
>> syntax):
>>
>> ({read,write}-subu8vector (u8vector) 0 0 port)
>>
>> That's a question for Marc I guess.
>>
>
> That will not do what you expect. If you ask for zero bytes then it
> will return immediately.
Yes, I wasn't clear about this: I *did* try the above and found it to
return immediately, which is why I then said so it's a question for you
to answer, and yes I was thinking that maybe making this case block
would possibly be a sensible way to offer what Mikael needs.
> I don't think it is a good idea to give a
> special meaning to the zero-bytes case.
>
Probably true.
> What you want is (peek-u8 port). It isn't defined but would be easy
> to add. An alternative would be a (wait-until-available-u8 n port)
> which blocks until at least n bytes are available to be read,
But the point is that Mikael does not want any bytes end up in Gambit's
I/O buffers; he just wants to make the Gambit scheduler report when I/O
is ready on a filehandle, on the OS level, so that his thread will
unblock and then call into an FFI function which then does the read(2)
system call on that fd. At least that's what I understood: i.e. that
libcurl allows one to call some proceed-reading and proceed-writing
procedures which will call read and write (or recv and send) on some
previously opened tcp sockets; and lets one take care of event handling
oneself; so Mikael needed a way to add those fd's to the bitmasks used
in the select call done by the Gambit scheduler and get some Scheme code
to run when such an fd is ready, but never wants Gambit to carry out an
actual read or write operation on those fd's.
Christian.
More information about the Gambit-list
mailing list