Hi folks,
What's with the ready-only arg to wait-for-input? It's not documented anywhere, but I noticed that if I don't pass T for it my code behaves strangely.
Cheers, -Mihai
Hi Mihai,
On Wed, Dec 16, 2009 at 12:00 PM, Mihai Bazon mihai@bazon.net wrote:
Hi folks,
What's with the ready-only arg to wait-for-input? It's not documented anywhere, but I noticed that if I don't pass T for it my code behaves strangely.
Without the READ-ONLY arg, WAIT-FOR-INPUT will return all sockets in the original list you passed it. This prevents a new list from being consed up. Some users of USOCKET were reluctant to use it if it wouldn't behave that way, expecting it to cost significant performance to do the associated garbage collection.
Without the READ-ONLY arg, you need to check the socket STATE slot for the values documented in usocket.lisp in the usocket class:
(state :initform nil :accessor state :documentation "Per-socket return value for the `wait-for-input' function.
The value stored in this slot can be any of NIL - not ready :READ - ready to read :READ-WRITE - ready to read and write :WRITE - ready to write
The last two remain unused in the current version. ")
HTH,
Erik.
Hi Erik,
Thanks for the reply! It does explain why my code doesn't work well without passing :READY-ONLY T (it probably tried to read from sockets that weren't ready, thus blocking the thread).
It's a pity that this arg is undocumented, and it should really be T by default (with NIL it defies the documented purpose of wait-for-input). I've spent a couple of hours fighting this out.
Cheers, -Mihai