On 2013-04-17, at 2:55 AM, Chun Tian (binghe) wrote: > I think it's reasonable to export more interfaces for WAIT-FOR-INPUT to make > it more efficiency for advanced users, but some of exist symbols (i.e. STATE) > may be too simple that it could be conflict with other packages or user > application, therefore I'm thinking a prefix WFI- or just WAIT- for all these > potential new exports. Do you have any suggestion?
To me, I think the most reasonable would be to export WAIT-LIST-WAITERS and a SOCKET-READABLE-P function that returns whether the state is :READ or not. Of course, it wouldn't be obvious that one has to WAIT-FOR-INPUT to make sure the SOCKET-READABLE-P is up-to-date. Another approach might be to have WAIT-FOR-INPUT take a function to call on the readable sockets. This would discourage anyone from disassociating the WAIT-FOR-INPUT and the READABLE state. (labels ((handle-socket-input (socket) … do something …)) (wait-for-input my-wait-list :timeout 0 :ready-func #'handle-socket-input)) and inside WAIT-FOR-INPUT: (when ready-func (dolist (sock (wait-list-waiters socket-or-sockets)) (when (eq (state sock) :read) (funcall ready-func sock))) I could go either way…. I just noticed that each USOCKET instance tracks which WAIT-LIST (if any) it is part of. I wasn't expecting that. I was expecting to be able to keep several WAIT-LISTs around (which may overlap) and use different ones at different times. Hmmm. Of course, with a quick look, I'm not seeing how it's being used on the front-end in any way except in ADD-WAITER, REMOVE-WAITER, and REMOVE-ALL-WAITERS. Maybe it's used on the backend? I'll have to look closer. Anyhow, you asked in the thread with Faré's patch if anyone would like to co-maintain. I'm pretty busy myself, but I wouldn't mind helping out. USOCKET is one of my favorite libs out there. Thanks, Patrick