On Fri, May 3, 2013 at 7:00 PM, Mircea Markus <mmarkus@redhat.com> wrote:

On 3 May 2013, at 16:54, Pedro Ruivo wrote:

> On 05/03/2013 04:49 PM, Manik Surtani wrote:
>>
>> On 2 May 2013, at 19:01, Pedro Ruivo <pedro@infinispan.org> wrote:
>>
>>>
>>> preciseTime() {return (cached = System.nanoTime());}
>>> impreciseTime() {return cached;}
>>
>> How would you invalidate the cached time?
>
> My idea is to have a schedule thread updating the cached time. the
> preciseTime() is just an optimization to keep the cached value more
> up-to-date since we are calculating the nanoTime() (and assuming that
> nanoTime() is more expensive than write in the volatile variable).

Sounds like a good idea but please don't implement that for now. That's a performance optimisation and would require benchmarking to prove it's worth doing - more of a nice to have ATM.


Actually, the performance optimization would be not to write the cached time in preciseTime would be the performance optimization.