-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sync_writes isn't working correctly when different values for function parameters are used #158
Comments
This is currently working as intended, but I understand the desire to only synchronize on a per key basis. Support for this could be added (preferably behind another macro arg like |
If you go here the docs say this: use cached::proc_macro::cached;
/// Cache an optional function. Only `Some` results are cached.
/// When called concurrently, duplicate argument-calls will be
/// synchronized so as to only run once - the remaining concurrent
/// calls return a cached value.
#[cached(size=1, option = true, sync_writes = true)]
fn keyed(a: String) -> Option<usize> {
if a == "a" {
Some(a.len())
} else {
None
}
} Which would indicate that it should function as I am describing no? But yes I see your point about requiring two locks... |
Yes, sorry the docs are incorrect! |
Ah no problem at all! P.S. I love this crate, it's an absolute joy to use. I do think I would find the |
The effect of that option is here: when true, the lock is just held for the function execution instead of being released for others to read cached/cached_proc_macro/src/cached.rs Line 236 in f1bcfd6
|
Here is my fn
calling concurrently with different values is causing the fn to execute sequentially which is not desired. Ex.
This will run sequentially and not concurrently. Removing
sync_writes = true
fixes the issue and it runs concurrently but obviously doesn't sync writes when the argument is the same. This is using v0.44.0The text was updated successfully, but these errors were encountered: