[gambit-list] Is long poll for activity on external file descriptors without Gambit reading data currently doable, and if so, how?
Marc Feeley
feeley at iro.umontreal.ca
Wed Sep 3 12:31:29 EDT 2008
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. I don't think it is a good idea to give a
special meaning to the zero-bytes case.
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, and
returns the number of bytes actually available to be read. The
implementation would have a reasonable upper limit on n. So you would
say (wait-until-available-u8 1 port) to block until at least one byte
is available, and (wait-until-available-u8 0 port) to get how many
bytes are available (without blocking).
What exactly do you need this for?
Marc
More information about the Gambit-list
mailing list