Re: The code example in onSpinWait() Javadoc

David Lloyd via Concurrency-interest <[email protected]>
Newsgroups gmane.comp.java.jsr.166-concurrency
Message-ID <CANghgrTeBuxb0FRPpMtc41_JwxEDV2v03TG8gynFvXGO-JL=VA@mail.gmail.com>
On Mon, Nov 18, 2019 at 4:37 AM Andrew Haley via Concurrency-interest
<[email protected]> wrote:
>
> On 11/17/19 11:46 PM, Doug Lea via Concurrency-interest wrote:
>
> > Usage may interact with GC, reference handling, and safepoints: in
> > some contexts "a short while" isn't usually short, but we don't have
> > a way of portably discussing such issues in javadocs. It's also one
> > of the reasons we don't include a spinlock utility -- we cannot
> > easily guess how best to write one that works well across enough
> > usage contexts. (But we do make it easy to write them via tryLock.)
>
> Sure, these ideas are hard to express if we restrict ourselves to
> the mythical "write once, run anywhere" Java, but by the time we're
> talking about writing our own spinlocks we're a long way from that.
>
> "Everybody" ;-) knows that you should only spin for about (half?) the
> same time as a simple system call, and that this is about 1000
> iterations of a trivial loop. Intuitively this makes sense: you don't
> want to make an (expensive) system call rather than just waiting for a
> little while.

Should we not express this sentiment in the documentation somehow even
if it is not perfectly applicable to every operating environment,
since it's clearly not widely understood?

-- 
- DML

_______________________________________________
Concurrency-interest mailing list
[email protected]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.