RFR: 8321242: Enable WorkerThreads to run tasks in caller thread [v6]
Erik Österlund
eosterlund at openjdk.org
Mon Dec 11 13:21:20 UTC 2023
On Mon, 11 Dec 2023 00:11:13 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:
>> The counter-argument is that when you see the Atomic::store you think that there must be some concurrent access happening, but there are none and the reader was just mislead by the Atomic::store.
>
> Since I made the suggestion - The rationale for using Atomic::store here is
> that _not_finished is conceptually an atomic variable, and we should always
> manipulate atomic variables using Atomic operations. It was ErikO who first
> espoused that style, and I thought there was general agreement on it.
>
> (I think it would be good to have an actual atomic variable class in HotSpot.
> Leo offered a prototype a while ago, but there were some problems with it and
> some lack of consensus around some parts, and it got put aside. I might be
> misremembering, but I think some of the problems were around things that could
> be dealt with using newer language features that we didn't have available at
> the time. I keep thinking about revisiting that area, but haven't gotten
> around to it, in part because I think I want C++17 for some things.)
What I have been saying is that atomic variables should be declared volatile so that anyone reading the declaration understands that it is an atomic variable and hence that you need to understand the code when accessing it. However, I find it quite confusing when people make explicit use of Atomic, when there is no actual concurrent access to worry about. Then my preference is to use normal accesses.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16945#discussion_r1422456836
More information about the hotspot-gc-dev
mailing list