Now that I'm reading this in the morning rather than at night, I agree that
having a utility method like notNow() or waitForClockToTick() makes sense.

In practice the System.currentTimeMillis() call has a granularity larger
than 1ms. I.e. if you do the following, you'll actually see 10ms steps (or
something):
while(true) System.out.println(System.currentTimeMillis())

-Darius

On Tue, Sep 13, 2011 at 8:17 AM, Burke Mamlin <[email protected]>wrote:

> I wasn't going for clearer.  When you suggested that the timestamp wasn't
> changing despite Sleep(10) and the "fix" was to pump it up to Sleep(100),
> that sounded a little fishy.  I was just suggesting checking for the
> condition needed (a new timestamp) instead of trying to wait long enough
> that it "should" be changed.  I'm not sure why a timestamp (to the
> millisecond) does not change with a Sleep(1).  I mean, isn't this always
> true?
>
> long t = new Date().getTime();
> sleep(1);
> assert new Date().getTime() != t;
>
> Even if the API was using a separate thread, a sleep(1) between steps
> should be enough to change the timestamp, right?
>
> -Burke
> On Tue, Sep 13, 2011 at 1:37 AM, Darius Jazayeri <[email protected]>wrote:
>
>> Um, if you think that's clearer, I can change it...
>>
>> -Darius (by phone)
>>
>>  On Sep 12, 2011 9:48 PM, "Burke Mamlin" <[email protected]> wrote:
>>
>> Instead of an arbitrary sleep time, how about something like this?
>>
>>  /* Blocks until timestamp changes */
>> function notNow() {
>>   long t = new Date().getTime();
>>   while (new Date().getTime() == t) {
>>     sleep(1);
>>   }
>> }
>>
>> // void obs
>> notNow();
>> // void patient
>> notNow();
>> // unvoid patient
>>
>> -Burke
>>
>>
>>
>> On Mon, Sep 12, 2011 at 9:45 PM, Darius Jazayeri <[email protected]>
>> wrote:
>> >
>> > In this case...
>>
>>   ------------------------------
>> Click here to 
>> unsubscribe<[email protected]?body=SIGNOFF%20openmrs-devel-l>from 
>> OpenMRS Developers' mailing list
>>
>>
> ------------------------------
> Click here to 
> unsubscribe<[email protected]?body=SIGNOFF%20openmrs-devel-l>from 
> OpenMRS Developers' mailing list
>

_________________________________________

To unsubscribe from OpenMRS Developers' mailing list, send an e-mail to 
[email protected] with "SIGNOFF openmrs-devel-l" in the  body (not 
the subject) of your e-mail.

[mailto:[email protected]?body=SIGNOFF%20openmrs-devel-l]

Reply via email to