You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am wondering about the interaction of is_fresh() and the coalescing of concurrent calls in insert_with():
This method guarantees that concurrent calls on the same not-existing entry are coalesced into one evaluation of the init future. Only one of the calls evaluates its future, and other calls wait for that future to resolve.
That is, will one of the concurrent calls return an Entry that is_fresh(), will all be considered fresh, or is there no such guarantee?
The text was updated successfully, but these errors were encountered:
Hi. Thank you for trying the new feature and asking the question.
Yes, there is a guarantee; is_fresh() must return true only when the init future of the or_insert_with call is resolved.
For example, when two concurrent or_insert_with calls (say call-A and call-B) on the same non-existing key were coalesced into one and call-A's init future was resolved, is_fresh of returned entries should return the following values:
is_fresh of the entry returned from call-A should return true.
is_fresh of the entry returned from call-B should return false.
This behavior was already implemented in the master branch via PR #193, but I realized test cases were missing. So I opened a new PR #218 to update the test cases to verify the behavior and also update the documentation to make the guarantee a bit more clear.
This method guarantees that concurrent calls on the same not-existing entry are coalesced into one evaluation of the init future. Only one of the calls evaluates its future (thus returned entry's is_fresh method returns true), and other calls wait for that future to resolve (and their is_fresh return false).
Hi, great work on the upcoming entry API!
I am wondering about the interaction of
is_fresh()
and the coalescing of concurrent calls ininsert_with()
:That is, will one of the concurrent calls return an
Entry
thatis_fresh()
, will all be considered fresh, or is there no such guarantee?The text was updated successfully, but these errors were encountered: