RE: [concurrency-interest] Deprecate all java.util.concurrent.*FieldUpdater

2016-10-05 Thread Justin Sampson
Deprecation is stronger than that -- it says "we're going to remove this, or we 
wish we could remove it because it's broken, so you'd better change your code 
a.s.a.p." -- e.g. Thread.stop(). My interpretation of Martin's comment is that 
using deprecation for things that aren't actually broken just means that people 
will live with lots of deprecation warnings in their code for years to come. 
This could be a perfect case for introducing a weaker alternative to 
deprecation, saying "here's something better that you should really be using 
for new code" -- e.g. ArrayList vs. Vector. I remember the Guava team talking 
about that a lot. Don't know if they ever implemented it.

Cheers,
Justin


-Original Message-
From: Concurrency-interest [mailto:concurrency-interest-boun...@cs.oswego.edu] 
On Behalf Of Andrew Haley
Sent: Wednesday, October 05, 2016 1:19 AM
To: Martin Buchholz; Remi Forax; Paul Sandoz
Cc: core-libs-dev; concurrency-interest
Subject: Re: [concurrency-interest] Deprecate all 
java.util.concurrent.*FieldUpdater

On 04/10/16 22:19, Martin Buchholz wrote:
> VarHandle is a reasonable replacement for FieldUpdaters, but it's not yet
> complete (where is accumulateAndGet?), and when do you deprecate something
> when the replacement won't be ubiquitous for 10 years?

Surely you have to start somewhere: deprecation is no more than saying
to programmers "Don't use this, use that."  And if you were leaning
over someone's shoulder that's what you would say.

Andrew.


___
Concurrency-interest mailing list
concurrency-inter...@cs.oswego.edu
http://cs.oswego.edu/mailman/listinfo/concurrency-interest


RE: [concurrency-interest] Is Reference.reachabilityFence() needed in Reference constructor?

2015-10-30 Thread Justin Sampson
Alex Otenko wrote:

> Wouldn't it be possible to add a test that will always be false?
>
> eg
> [...]
> if (get() != referent) {
> [...]
>
> The point being that referent would need to stay alive due to
> Java semantics to align with get() and queue assignment.

Couldn't the compiler just inline get() as this.referent, see that
this.referent was just set to referent, and simplify this.referent
!= referent to false?

Cheers,
Justin


RE: [concurrency-interest] Why not weakNanoTime for jdk9?

2015-03-10 Thread Justin Sampson
Aleksey Shipilev wrote:

 It would really help if you list what problems weakNanoTime is
 supposed to solve.

I was talking to Martin about this idea recently so I'll take a shot
at describing why it's appealing to me (with the usual disclaimer
that I know I'm much less of an expert than most other folks here).

The main case I'm interested in is handling timeout calculations in
concurrent operations. The usual case should be that the operation
succeeds without timing out, and if it _does_ time out it's often
after waiting several seconds or minutes, in which case being off
by, say, a few microseconds is not a big deal.

Given those assumptions, we really want the usual case (success) to
be as fast as possible, and especially not to impose any additional
synchronization or volatile accesses. Since strict monotonicity
requires checking some kind of centrally synchronized clock state,
it fails that use case.

Furthermore, in this particular use case, it's trivial to have the
appearance of monotonicity _within_ a particular operation: Just
keep a local variable with the last time seen, and only update it if
the next time seen is greater than the last time seen. No extra
synchronization is required.

The semantics I'm imagining would be for a very fast timer that is
_usually_ monotonic, as long as the current thread stays on one
processor, with occasional blips when switching between processors.
We would still want those blips to be as small as practically
achievable, so I guess there would still have to be some occasional
synchronization to keep the fast timer within some tolerance of the
central system clock.

The way I see it, good concurrency semantics are about acknowledging
the reality of the hardware, and a strictly monotonic clock is
simply not the reality of the hardware when there's more than one
processor involved.

Actually, come to think of it, given an underlying non-monotonic
timer, the weakNanoTime method could easily provide monotonicity on
a per-thread basis without any synchronization overhead. That would
mean most concurrent code wouldn't even have to change to become
tolerant of non-monotonicity. It would just have to be made really
clear to users that different threads might see timer values out of
order relative to each other, though still within some best-effort
tolerance.

Cheers,
Justin