hawkw/mycelium

`WaitMap` could have a mechanism to wake a waiter but immediately requeue it

Opened this issue · 3 comments

hawkw commented

cc @jamesmunns

Currently, when waking a task waiting on a WaitMap, the task's entry is always removed from the list. This means that it won't be notified again if we wake the same key with a different value. This makes it difficult to implement "stream-style" rather than "request-response style" APIs using WaitMap.

@hawkw this seems neat, though WaitMap only holds an intrusive handle to a single item, and wake is not async.

Is the intent to use this sort of like a channel router? It seems like that feels more like HashMap<K, Sender<V>> or something (which also seems useful!).

hawkw commented

Yeah...I'm not actually sure if this is the right use-case for WaitMap. I started working on a "server-streaming" style API for Calliope request-response, but I think, after further consideration, that it doesn't really make sense as a thing to add.

Yeah, WaitMap is sort of like a HashMap<K, IntrusivelyStoredOneShot<T>>, honestly.