Re: Concurrent Hash Map javadoc question

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Concurrent Hash Map javadoc question

JSR166 Concurrency mailing list
Hi Keith,

I think this is one for concurrency interest to answer.

Cheers,
Martijn


On Tue, 17 Sep 2019 at 12:48, Keith Turner <[hidden email]> wrote:
The javadoc for ConcurrentHashMap.computeIfAbsent() states the
remapping function is applied at most once.  The functions
computeIfPresent() and compute() do not explicitly state if the
remapping functions could possibly be run multiple times. Does anyone
know if computeIfPresent() and compute() are guaranteed to only run
the remapping functions at most once?  If so, should the javadoc be
updated?

Thanks,

Keith

_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest
Reply | Threaded
Open this post in threaded view
|

Re: Concurrent Hash Map javadoc question

JSR166 Concurrency mailing list
I think this doc difference is intentional.

In case of a retry loop, the value may have changed in the case of computeIfPresent or compute and so the function must be called again with the new value.

On Tue, Sep 17, 2019 at 4:36 PM Martijn Verburg <[hidden email]> wrote:
Hi Keith,

I think this is one for concurrency interest to answer.

Cheers,
Martijn


On Tue, 17 Sep 2019 at 12:48, Keith Turner <[hidden email]> wrote:

> The javadoc for ConcurrentHashMap.computeIfAbsent() states the
> remapping function is applied at most once.  The functions
> computeIfPresent() and compute() do not explicitly state if the
> remapping functions could possibly be run multiple times. Does anyone
> know if computeIfPresent() and compute() are guaranteed to only run
> the remapping functions at most once?  If so, should the javadoc be
> updated?
>
> Thanks,
>
> Keith
>

_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest
Reply | Threaded
Open this post in threaded view
|

Re: Concurrent Hash Map javadoc question

JSR166 Concurrency mailing list
All three state that "The entire method invocation is performed atomically" and computeIfAbsent merely explains this with the addition "so the function is applied at most once per key." Since all computations are atomic operations in ConcurrentHashMap, this seems to be implied in the other cases rather than explicitly clarified. 

On Tue, Sep 17, 2019 at 6:36 PM Martin Buchholz via Concurrency-interest <[hidden email]> wrote:
I think this doc difference is intentional.

In case of a retry loop, the value may have changed in the case of computeIfPresent or compute and so the function must be called again with the new value.

On Tue, Sep 17, 2019 at 4:36 PM Martijn Verburg <[hidden email]> wrote:
Hi Keith,

I think this is one for concurrency interest to answer.

Cheers,
Martijn


On Tue, 17 Sep 2019 at 12:48, Keith Turner <[hidden email]> wrote:

> The javadoc for ConcurrentHashMap.computeIfAbsent() states the
> remapping function is applied at most once.  The functions
> computeIfPresent() and compute() do not explicitly state if the
> remapping functions could possibly be run multiple times. Does anyone
> know if computeIfPresent() and compute() are guaranteed to only run
> the remapping functions at most once?  If so, should the javadoc be
> updated?
>
> Thanks,
>
> Keith
>
_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest

_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest
Reply | Threaded
Open this post in threaded view
|

Re: Concurrent Hash Map javadoc question

JSR166 Concurrency mailing list
How about
The entire method invocation is performed atomically, so the function is applied at most once per key.
=>
The entire method invocation is performed atomically.  The function is applied at most once per key.

On Tue, Sep 17, 2019 at 7:08 PM Benjamin Manes <[hidden email]> wrote:
All three state that "The entire method invocation is performed atomically" and computeIfAbsent merely explains this with the addition "so the function is applied at most once per key." Since all computations are atomic operations in ConcurrentHashMap, this seems to be implied in the other cases rather than explicitly clarified. 

On Tue, Sep 17, 2019 at 6:36 PM Martin Buchholz via Concurrency-interest <[hidden email]> wrote:
I think this doc difference is intentional.

In case of a retry loop, the value may have changed in the case of computeIfPresent or compute and so the function must be called again with the new value.

On Tue, Sep 17, 2019 at 4:36 PM Martijn Verburg <[hidden email]> wrote:
Hi Keith,

I think this is one for concurrency interest to answer.

Cheers,
Martijn


On Tue, 17 Sep 2019 at 12:48, Keith Turner <[hidden email]> wrote:

> The javadoc for ConcurrentHashMap.computeIfAbsent() states the
> remapping function is applied at most once.  The functions
> computeIfPresent() and compute() do not explicitly state if the
> remapping functions could possibly be run multiple times. Does anyone
> know if computeIfPresent() and compute() are guaranteed to only run
> the remapping functions at most once?  If so, should the javadoc be
> updated?
>
> Thanks,
>
> Keith
>
_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest

_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest
Reply | Threaded
Open this post in threaded view
|

Re: Concurrent Hash Map javadoc question

JSR166 Concurrency mailing list
Please drop the discuss@openjdk list from this exchange - thanks.

David

On 18/09/2019 12:19 pm, Martin Buchholz wrote:

> How about
> The entire method invocation is performed atomically, so the function is
> applied at most once per key.
> =>
> The entire method invocation is performed atomically.  The function is
> applied at most once per key.
>
> On Tue, Sep 17, 2019 at 7:08 PM Benjamin Manes <[hidden email]> wrote:
>
>> All three state that "The entire method invocation is performed
>> atomically" and computeIfAbsent merely explains this with the addition "so
>> the function is applied at most once per key." Since all computations are
>> atomic operations in ConcurrentHashMap, this seems to be implied in the
>> other cases rather than explicitly clarified.
>>
>> On Tue, Sep 17, 2019 at 6:36 PM Martin Buchholz via Concurrency-interest <
>> [hidden email]> wrote:
>>
>>> I think this doc difference is intentional.
>>>
>>> In case of a retry loop, the value may have changed in the case of
>>> computeIfPresent or compute and so the function must be called again with
>>> the new value.
>>>
>>> On Tue, Sep 17, 2019 at 4:36 PM Martijn Verburg <[hidden email]>
>>> wrote:
>>>
>>>> Hi Keith,
>>>>
>>>> I think this is one for concurrency interest to answer.
>>>>
>>>> Cheers,
>>>> Martijn
>>>>
>>>>
>>>> On Tue, 17 Sep 2019 at 12:48, Keith Turner <[hidden email]> wrote:
>>>>
>>>>> The javadoc for ConcurrentHashMap.computeIfAbsent() states the
>>>>> remapping function is applied at most once.  The functions
>>>>> computeIfPresent() and compute() do not explicitly state if the
>>>>> remapping functions could possibly be run multiple times. Does anyone
>>>>> know if computeIfPresent() and compute() are guaranteed to only run
>>>>> the remapping functions at most once?  If so, should the javadoc be
>>>>> updated?
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Keith
>>>>>
>>>>
>>> _______________________________________________
>>> Concurrency-interest mailing list
>>> [hidden email]
>>> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>>>
>>
_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest
Reply | Threaded
Open this post in threaded view
|

Re: Concurrent Hash Map javadoc question

JSR166 Concurrency mailing list
In reply to this post by JSR166 Concurrency mailing list
I was wrong and filed
  1. DK
  2. JDK-8231592

Clarify that ConcurrentHashMap compute methods mapping functions execute at most once




On Wed, Sep 18, 2019 at 7:23 AM Keith Turner <[hidden email]> wrote:
On Tue, Sep 17, 2019 at 9:35 PM Martin Buchholz <[hidden email]> wrote:
>
> I think this doc difference is intentional.

If that is the case, it would be really nice update the javadoc to
make it explicit.

>
> In case of a retry loop, the value may have changed in the case of computeIfPresent or compute and so the function must be called again with the new value.
>
> On Tue, Sep 17, 2019 at 4:36 PM Martijn Verburg <[hidden email]> wrote:
>>
>> Hi Keith,
>>
>> I think this is one for concurrency interest to answer.
>>
>> Cheers,
>> Martijn
>>
>>
>> On Tue, 17 Sep 2019 at 12:48, Keith Turner <[hidden email]> wrote:
>>
>> > The javadoc for ConcurrentHashMap.computeIfAbsent() states the
>> > remapping function is applied at most once.  The functions
>> > computeIfPresent() and compute() do not explicitly state if the
>> > remapping functions could possibly be run multiple times. Does anyone
>> > know if computeIfPresent() and compute() are guaranteed to only run
>> > the remapping functions at most once?  If so, should the javadoc be
>> > updated?
>> >
>> > Thanks,
>> >
>> > Keith
>> >

_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest