[concurrency-interest] The code example in onSpinWait() Javadoc

Roman Leventov leventov.ru at gmail.com
Fri Nov 15 10:55:07 EST 2019


I agree that Javadoc code shouldn't be a tutorial - that is why I also
proposed to delete the example completely. But I think the current example
is a little bit of anti-tutorial. To cite Josh Bloch - "Example code should
be exemplary. If an API is used widely, its examples will be the archetypes
for thousands of programs. Any mistakes will come back to haunt you a
thousand fold."

On Fri, 15 Nov 2019 at 18:04, Andrew Haley via Concurrency-interest <
concurrency-interest at cs.oswego.edu> wrote:

> On 11/15/19 1:31 PM, Alex Otenko via Concurrency-interest wrote:
> > I am not arguing. I want to see justification for wanting something that
> > looks like a solution to an intractable problem.
> >
> > I see onSpinWait as an indicator to the JVM that it can do something
> > useful, like possibly help FJP make some progress. I can't see how a time
> > bound can be enforced there.
>
> But that is not what "onSpinWait" means, that is what "yield" means.
> The idea of "onSpinWait" is to reduce latency in spin loops, where
> latency is measured in tens of nanoseconds. "onSpinWait" is not
> supposed to free the processor to do something else.
>
> I don't think there's anything much wrong with the example in the Javadoc,
> and the Javadoc is not supposed to be a tutorial.
>
> --
> Andrew Haley  (he/him)
> Java Platform Lead Engineer
> Red Hat UK Ltd. <https://www.redhat.com>
> https://keybase.io/andrewhaley
> EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671
>
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20191115/26a75581/attachment.html>


More information about the Concurrency-interest mailing list