[racket-dev] scheme_sema_post_all

From: Tony Garnock-Jones (tonyg at ccs.neu.edu)
Date: Sat Oct 22 09:41:29 EDT 2011

Hi all,

It looks like scheme_sema_post_all has the effect of an infinite number
of scheme_sema_post calls. Is that right? If so, that's exactly what I
need: would it make sense to expose the functionality, perhaps as
(semaphore-post-infinite) or (semaphore-post-all)?

(Context: I want to build a kind of box that starts empty, is able to be
given a value exactly once, and that threads can wait on until its value
is set by some other thread. Currently I'm using a channel and a
newly-spun-up thread that loops in a channel-put, but it's not kill-safe
I don't think, and creating a thread whenever the box is filled is quite
heavy compared to doing a scheme_sema_post_all. Incidentally, the
behaviour I'm after is very similar to (thread-dead-evt). I'll be using
it, among other things, to hold the fatal exception that killed a
thread, if any.)


Posted on the dev mailing list.