On Fri, 2018-07-20 at 11:27 -0400, Kim van der Riet wrote:
> ...
> I am using the timer in periodic mode, ie with period set to an
> interval 

Thanks for describing what you are trying to do: As I mentioned earlier
your case best matches the one-shot mode not the periodic mode.

> ...
> The idea is as follows: If the timer fires after some journal
> activity 
> (but not enough to fill the write buffer), the journal is flushed.
> Only 
> when new journal activity occurs, setUpNextFire() is called to start
> the 
> timer again.

I think this is incorrect usage: You should be using restart() to delay
timer firing whenever the journal gets flushed by the journal writes.
Once the one-shot is fired you need to create a new TimerTask for
further timed flushes.

I think that your code is overcomplicated for what it needs to do. The
effect you seek is to timeout after journal flushes, in this case you
only need to create a one-shot TimerTask (and recreate it whenever it
gets fired). Whenever the journal code flushes because it has enough
data it uses restart() to delay the timer firing.

If the timer fires then we know that the timer time has elapsed since
the last journal flush and we do a flush. In this case we need to
create a new TimerTask as the one-shot has fired and cannot be used
again.

Andrew

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to