I'm writing a program in SBCL that uses serve-event to listen for
input on a bunch of sockets. I have an initialization function that
sets up the appropriate fd-handlers and returns. When I call this
function, then return to the REPL, everything goes as it should - the
incoming events get served. But when the initialization function is
called by other code, which then goes on to do other things, the input
does not get handled. I see from previous messages that this is
because the REPL calls serve-event when waiting for input. So I tried
starting another thread to do this: at the end of my initialization
function, I call
(sb-sys:make-thread #'(lambda () (loop (when *done* (return)) (sb-
sys:serve-event))))
(where *done* is set elsewhere). But this still does not work: am I
missing something here? I am using slime with communication-style set
to :fd-handler and globally-redirect-io is true.
- Bhaskara
On Oct 9, 12:49 am, basman <········@gmail.com> wrote:
> I call
>
> (sb-sys:make-thread #'(lambda () (loop (when *done* (return)) (sb-
> sys:serve-event))))
Not sure what version of SBCL you are using, but I only have
SB-THREAD:make-thread...
On Oct 9, 2:22 am, "Leslie P. Polzer" <·············@gmx.net> wrote:
> On Oct 9, 12:49 am, basman <········@gmail.com> wrote:
>
> > I call
>
> > (sb-sys:make-thread #'(lambda () (loop (when *done* (return)) (sb-
> > sys:serve-event))))
>
> Not sure what version of SBCL you are using, but I only have
> SB-THREAD:make-thread...
You're right... I did use sb-thread:make-thread actually. Can you see
what the problem might be? Upon thinking about it further, I was
wondering if the problem could be that the event-queue for serve-event
is separate for each thread, and that in SLIME all events go into the
queue of the thread that contained the initial REPL. Could any SLIME
experts tell me if this right and if so, how to get around it?
- Bhaskara
On Oct 9, 8:23 am, basman <········@gmail.com> wrote:
> On Oct 9, 2:22 am, "Leslie P. Polzer" <·············@gmx.net> wrote:
>
> > On Oct 9, 12:49 am, basman <········@gmail.com> wrote:
>
> > > I call
>
> > > (sb-sys:make-thread #'(lambda () (loop (when *done* (return)) (sb-
> > > sys:serve-event))))
>
> > Not sure what version of SBCL you are using, but I only have
> > SB-THREAD:make-thread...
>
> You're right... I did use sb-thread:make-thread actually. Can you see
> what the problem might be? Upon thinking about it further, I was
> wondering if the problem could be that the event-queue for serve-event
> is separate for each thread, and that in SLIME all events go into the
> queue of the thread that contained the initial REPL. Could any SLIME
> experts tell me if this right and if so, how to get around it?
> - Bhaskara
OK, for future googlers - the issue, which was surprisingly hard to
find online, was that there's a serve-event queue per thread, and add-
fd-handler adds its handler to the queue of the current thread,
whereas my code had been adding the fd-handler in a different thread
from the serve-event loop.