[racket-dev] feature request: thread-safe memoize-evt
Hi,
I would like to ask for another extension of the Racket's event handling
system. A `memoize-evt` constructor with following semantics:
Given a base event E_b, memoize-evt will produce a memoizing event E_m.
Synchronizing on E_m from any number of threads will block until a
single value is produced by E_b. This value is then stored inside the
E_m. From that moment on, E_m will always be immediately ready for
synchronization and produce the stored value in all waiting threads.
The single-threaded implementation is a trivial guard-evt + replace-evt
+ (wrap-evt always-evt) combo, but for thread-safety a temporary thread
would be needed to wait for the base event and the solution would have
different semantics then rest of the event system.
A lower-level approach would also be possible; create something along
the lines of a dynamic-wind-evt that would, with some cleverness, allow
for generic thread-safe events via locking. Or create a locked-wrap-evt
constructor that will not be ready until it's handler finishes.
Hoping that I am not being too bothersome,
from Prague with thanks,
Jan Dvorak