[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Threading, mailboxes, and exceptions
From: |
jared jennings |
Subject: |
Threading, mailboxes, and exceptions |
Date: |
Fri, 03 Mar 2023 08:30:00 -0500 |
User-agent: |
K-9 Mail for Android |
Hi everyone! I'm working on my first program in Chicken Scheme. I've got five
or six long-running threads, plus workers spun out occasionally. A couple of
the long-running ones act like services: they listen for requests in a mailbox,
do a thing, then respond.
One of those is supposed to block its caller, so the caller thread passes
itself in the request, sends, then suspends itself. The service does its job
then resumes the thread indicated in the request, ie the caller.
In another case I want to pass a value back, so the caller makes a mailbox and
passes that in the request.
Now say something goes wrong. I want the caller to know. In the first case I
have the thread; I can use thread-signal!. In the second case I have to add
more, eg pass the caller thread *and* a mailbox.
Is there an elegant way I've missed that lets me get back (a) a value, or (b) a
resumption, or (c) a condition, with one mechanism?
Also I'm from Python land, where exceptions are never resumable. The YouTube
talks about Common Lisp rave about conditions, mostly in the context of
interactive development ("Call a function that doesn't exist yet!" etc). Now
here I see exceptions and conditions, and they are well enough documented that
I can catch them, but I don't feel like I really understand them. Where does
one learn about Scheme conditions and why they are what they are and not
something different?
- Threading, mailboxes, and exceptions,
jared jennings <=