I have an axum
server with a state struct. In it I want to use delay_map::HashMapDelay
to keep a map of sessions that are removed after a timeout. Since the state is shared, the map is under a tokio::sync::RwLock
.
But from what I understand, in order to actually remove the expired entries, I need to call next()
since it's a Stream
. So I'm trying to spawn a task that does that in a loop. However, since the map is behind a RwLock
, I can't make that work, it gets stuck; I think it deadlocks since it needs to hold the lock while it waits in the next()
call.
Any suggestions on how to make this work, or maybe a totally different approach to do the same thing?
2 posts - 2 participants