[racket-dev] feature request: thread-safe memoize-evt
Thanks for your time.
On Thu, 2015-01-29 at 12:55 -0700, Matthew Flatt wrote:
> Would the simpler `once-evt` work in your situation, or do you need the
> guarantee that only one wait of E happens at a time?
OK, my original goal is to implement a remote method call multiplexer.
The kind where you send a message with an identifier and the remote
party eventually replies with the same identifier or possibly with a
well-known one to indicate an out-of-bound notification.
So, I'd like to end up with (something-receive-evt something key) and
(something-call-evt something key request).
I can see two ways to do that;
1. Have a dispatch table with pending messages.
2. Broadcast all incoming messages to all waiters.
Dispatch table requires non-racy invalidation of pending requests to
prevent resource leaks.
Broadcasting messages requires construction of a thread-safe memoizing
event combinator (produces next-evt and a single result).
Also, I have a feeling that I could get close to (1) if I keep some
cleanup thread and utilize nack-guard-evt, but something tells me it
might be racy.
Best regards,
Jan Dvorak