hawkw / mycelium

🍄 an alleged 'operating system'
https://mycelium.elizas.website
MIT License
537 stars 19 forks source link

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

Open hawkw opened 10 months ago

hawkw commented 10 months ago

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.

jamesmunns commented 10 months ago

@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 10 months ago

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.

jamesmunns commented 10 months ago

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