Closed stefnotch closed 3 weeks ago
So just to start off: On a memo, taking one read lock and reusing it will always be better than taking multiple read locks, on a memo.
This is because .read()
doesn't simply take a read-lock on the inner value: it has to run the reactive tracking logic as well. The tracking logic, not the current value, is what's causing the issue here. Specifically, calling .read()
on the memo needs to be able to update the memo's current state.
I also expect Leptos to panic when trying to get a write guard while a read guard is alive.
This library does not add any special behavior to what Rust's std::sync::RwLock
does in this scenario, which is apparently to deadlock.
Thank you for the quick fix! And yes, of course only having one guard is smarter. I just ran into it while doing some very nested function calls, and realising that something was causing my app to deadlock.
Describe the bug I cannot call
.read
more than once without causing reactive_graph (0.1.0-gamma3) to hangLeptos Dependencies
To Reproduce
Expected behavior I expected it to be possible to acquire multiple read guards. I also expect Leptos to panic when trying to get a write guard while a read guard is alive.