Re: RFR(s) #2: 6344935: (spec) clarify specifications for Object.wait overloads

2017-08-25 Thread Stuart Marks
On 8/25/17 11:34 AM, Martin Buchholz wrote: Stuart, you have my blessing to commit what you have, even though both your reviewers are still nitpicking that wait loop. OK, thanks, I was thinking the same thing. :-) s'marks

Re: RFR(s) #2: 6344935: (spec) clarify specifications for Object.wait overloads

2017-08-25 Thread Martin Buchholz
Stuart, you have my blessing to commit what you have, even though both your reviewers are still nitpicking that wait loop. The thing that bothers me in while ( and ) { long timeout = ... ; // recompute timeout values is that you can't check for until you've done the

Re: RFR(s) #2: 6344935: (spec) clarify specifications for Object.wait overloads

2017-08-24 Thread David Holmes
On 25/08/2017 3:26 PM, Martin Buchholz wrote: On Thu, Aug 24, 2017 at 7:49 PM, David Holmes > wrote: I have no further comments on the actual spec. Here's my suggestion for the timed-wait example :) while (true) {   if

Re: RFR(s) #2: 6344935: (spec) clarify specifications for Object.wait overloads

2017-08-24 Thread Martin Buchholz
On Thu, Aug 24, 2017 at 7:49 PM, David Holmes wrote: > I have no further comments on the actual spec. > > Here's my suggestion for the timed-wait example :) > > while (true) { > if (!condition) > wait(timeout, nanos); > else > break; // condition holds > >

Re: RFR(s) #2: 6344935: (spec) clarify specifications for Object.wait overloads

2017-08-24 Thread David Holmes
I have no further comments on the actual spec. Here's my suggestion for the timed-wait example :) while (true) { if (!condition) wait(timeout, nanos); else break; // condition holds if (timeout <= 0 && !condition) throw new TimedOutException(); } // Perform action

Re: RFR(s) #2: 6344935: (spec) clarify specifications for Object.wait overloads

2017-08-24 Thread Stuart Marks
On 8/20/17 6:32 PM, David Holmes wrote: You're a brave man :) "It's a dirty job, but somebody's gotta do it." :-) I have a personal interest in this, as back in the 1.3 days I was trying to nail down some multi-threaded code, and I found the wait() docs to be quite lacking. In particular,

Re: RFR(s) #2: 6344935: (spec) clarify specifications for Object.wait overloads

2017-08-22 Thread Martin Buchholz
Here's a plan: Stuart commits his improvements, we then improve the code snippet in TimeUnit.timedWait, then change wait(long, int) api note to point at that. We can also add a "time-less" wait loop code snippet to the spec for nullary wait().

Re: RFR(s) #2: 6344935: (spec) clarify specifications for Object.wait overloads

2017-08-22 Thread Martin Buchholz
awaitUntil(Date) is weird in that it takes a wall clock Date that is subject to system administrator action like date(1). And Date is one of those classes everyone loves to hate.

Re: RFR(s) #2: 6344935: (spec) clarify specifications for Object.wait overloads

2017-08-21 Thread Martin Buchholz
On Sun, Aug 20, 2017 at 9:53 PM, David Holmes wrote: > On 21/08/2017 2:07 PM, Martin Buchholz wrote: > >> On Sun, Aug 20, 2017 at 6:36 PM, David Holmes > > wrote: >> >> On 20/08/2017 6:37 AM, Martin Buchholz

Re: RFR(s) #2: 6344935: (spec) clarify specifications for Object.wait overloads

2017-08-21 Thread Martin Buchholz
My attempt to write a good wait loop led me to want only to use a nanosecond wait method. And in fact we have existing method Condition.awaitNanos for inspiration. For a moment I considered adding Object#waitNanos but then I came to my senses. But we could add a static method Objects#waitNanos

Re: RFR(s) #2: 6344935: (spec) clarify specifications for Object.wait overloads

2017-08-21 Thread Martin Buchholz
Using a boolean flag is reasonable, but there are micro-defects here as well: - There's a dead initial store to deadline just to appease the definite assignment algorithm. - the scope of deadline and remaining leaks into the post-wait-loop code, and it would be ugly to introduce a new scope

Re: RFR(s) #2: 6344935: (spec) clarify specifications for Object.wait overloads

2017-08-21 Thread Peter Levart
Hi Martin, On 08/21/2017 05:05 AM, Martin Buchholz wrote: On Sat, Aug 19, 2017 at 1:53 PM, Martin Buchholz wrote: Now I see that the code snippet in TimeUnit.timedWait is also in need of fixing. H public synchronized Object poll(long timeout, TimeUnit unit)

Re: RFR(s) #2: 6344935: (spec) clarify specifications for Object.wait overloads

2017-08-20 Thread David Holmes
On 21/08/2017 2:07 PM, Martin Buchholz wrote: On Sun, Aug 20, 2017 at 6:36 PM, David Holmes > wrote: On 20/08/2017 6:37 AM, Martin Buchholz wrote: Future projects: 377 * The specified amount of real time has

Re: RFR(s) #2: 6344935: (spec) clarify specifications for Object.wait overloads

2017-08-20 Thread Martin Buchholz
On Sun, Aug 20, 2017 at 6:36 PM, David Holmes wrote: > On 20/08/2017 6:37 AM, Martin Buchholz wrote: > >> Future projects: >> >> 377 * The specified amount of real time has elapsed, more or less. >> >> Replace with >> >> * At least the specified amount of real time has

Re: RFR(s) #2: 6344935: (spec) clarify specifications for Object.wait overloads

2017-08-20 Thread Martin Buchholz
On Sat, Aug 19, 2017 at 1:53 PM, Martin Buchholz wrote: > Now I see that the code snippet in TimeUnit.timedWait is also in need of > fixing. H > > public synchronized Object poll(long timeout, TimeUnit unit) > throws InterruptedException { >while (empty)

Re: RFR(s) #2: 6344935: (spec) clarify specifications for Object.wait overloads

2017-08-20 Thread David Holmes
On 20/08/2017 6:37 AM, Martin Buchholz wrote: Future projects: 377 * The specified amount of real time has elapsed, more or less. Replace with * At least the specified amount of real time has elapsed. (I think I failed to persuade David last time ...) And you will continue to do so. :) In

Re: RFR(s) #2: 6344935: (spec) clarify specifications for Object.wait overloads

2017-08-20 Thread David Holmes
Hi Stuart, You're a brave man :) I shall refrain from mentioning any of the existing wording quirks that really irritate me. :) On 19/08/2017 5:59 AM, Stuart Marks wrote: Hi all, Well nothing is ever simple, is it? Prompted by David Holmes' comments, I looked at the other overloads of

Re: RFR(s) #2: 6344935: (spec) clarify specifications for Object.wait overloads

2017-08-19 Thread Martin Buchholz
Now I see that the code snippet in TimeUnit.timedWait is also in need of fixing. H public synchronized Object poll(long timeout, TimeUnit unit) throws InterruptedException { while (empty) { unit.timedWait(this, timeout); ... } }

Re: RFR(s) #2: 6344935: (spec) clarify specifications for Object.wait overloads

2017-08-19 Thread Martin Buchholz
Good work! On Fri, Aug 18, 2017 at 12:59 PM, Stuart Marks wrote: > > Well nothing is ever simple, is it? Especially not when you're modifying Object, and have the pickiest reviewers on the planet! More picky comments you are free to ignore: 432 * @param

Re: RFR(s) #2: 6344935: (spec) clarify specifications for Object.wait overloads

2017-08-19 Thread Martin Buchholz
Future projects: 377 * The specified amount of real time has elapsed, more or less. Replace with * At least the specified amount of real time has elapsed. (I think I failed to persuade David last time ...) --- We should add a @see to TimeUnit.timedWait which at least deals with

Re: RFR(s) #2: 6344935: (spec) clarify specifications for Object.wait overloads

2017-08-18 Thread Remi Forax
looks good. It's better than the previous wording. cheers, Rémi - Mail original - > De: "Stuart Marks" <stuart.ma...@oracle.com> > À: "core-libs-dev" <core-libs-dev@openjdk.java.net> > Envoyé: Vendredi 18 Août 2017 21:59:25 > Objet: RFR(s

RFR(s) #2: 6344935: (spec) clarify specifications for Object.wait overloads

2017-08-18 Thread Stuart Marks
Hi all, Well nothing is ever simple, is it? Prompted by David Holmes' comments, I looked at the other overloads of wait(), and I agree that they're in need of cleanup. I decided to put the most complete version of the specification into the wait(timeout, nanos) overload, and then I simply