-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
LoadingCacheView.asMap()'s computeIfPresent blocks on Future completion while remove(key, value) doesn't #156
Comments
The likely thought process was that if value in a |
Oh, I misread this. A Potentially offering an |
I think the blocking semantics you mentioned here makes total sense given that's very common in the Java ecosystem. I think having the option to choose between a blocking interface or a non-blocking one will prove to be beneficial for everyone. Is this simply just exposing |
It sounds like I need to review the Unfortunately exposing a |
An in-flight future was mistakenly given the maximum expiry allowed, causing it to not honor an expire-after-create setting. Instead it was supposed to be beyond the maximum to signal adaption on the completion update. The calculations for fixed expiration was made more robust to the time rolling over. This now complies with System.nanoTime() warnings. Strengthened the remove and replace operations to be more predictably linearizable. This removed optimizations to avoid unnecessary work by checking if the entry was present in a lock-free manner. Since the hash table supresses loads until complete, that might mean that a call to remove a loading entry was not performed. The contract allows either, so the optimization is left to user code and gives preference to those who need the linearizable behavior. (See #156)
An in-flight future was mistakenly given the maximum expiry allowed, causing it to not honor an expire-after-create setting. Instead it was supposed to be beyond the maximum to signal adaption on the completion update. The calculations for fixed expiration was made more robust to the time rolling over. This now complies with System.nanoTime() warnings. Strengthened the remove and replace operations to be more predictably linearizable. This removed optimizations to avoid unnecessary work by checking if the entry was present in a lock-free manner. Since the hash table supresses loads until complete, that might mean that a call to remove a loading entry was not performed. The contract allows either, so the optimization is left to user code and gives preference to those who need the linearizable behavior. (See #156)
An in-flight future was mistakenly given the maximum expiry allowed, causing it to not honor an expire-after-create setting. Instead it was supposed to be beyond the maximum to signal adaption on the completion update. The calculations for fixed expiration was made more robust to the time rolling over. This now complies with System.nanoTime() warnings. Strengthened the remove and replace operations to be more predictably linearizable. This removed optimizations to avoid unnecessary work by checking if the entry was present in a lock-free manner. Since the hash table supresses loads until complete, that might mean that a call to remove a loading entry was not performed. The contract allows either, so the optimization is left to user code and gives preference to those who need the linearizable behavior. (See #156)
I strengthened the methods to block rather than optimistically skip. I'll try to look into the async asMap view soon. |
I've been working on this lately, sorry its taken so long. This will introduce an asynchronous map view on the newly introduced You'll now have So far it passes Guava's TestLib, which has robust collections testing. I am still porting a copy of |
Released 2.7 |
When attempting to implement an atomic
removeIf
operation for AsyncLoadingCache i found out thatLoadingCacheView
computeIfPresent seems to block, while remove doesn't. (computeIfPresent
callsAsync.getWhenSuccessful(oldValueFuture)
whileremove
callsAsync.getIfReady(oldValueFuture)
)This is surprising to me because semantic-wise, I should be able to implement remove in terms of computeIfPresent (Neither of them should block)
Is there a reason for the blocking semantics for computeIfPresent?
Example (Excuse the pseudo Scala here):
The text was updated successfully, but these errors were encountered: