Re: glib: GTimer patch for elapsed time

Gavin Baker <gavinb antonym org> writes:

> Greetings,
> On Wed, 2002-07-10 at 09:55, Owen Taylor wrote:
> > 
> > Gavin Baker <gavinb antonym org> writes:
> > > [...]
> > > The GTimer in glib resets the clock at each call to gtk_timer_start(). 
> > > Thus it is incapable of tracking true elapsed time across consecutive
> > > calls to start-stop.  This rather defeats the purpose of having a timer
> > > object, since you then have to implement elapsed time tracking yourself.
> > > [...]
> > 
> > This isn't a change we can make. 
> > 
> >
> > 
> > Describes the current behavior, and even if it didn't people would
> > be very likely relying on the current behavior. An incompatible change
> > could only be made for GLib-3.0, and even then we try very hard
> > to avoid incompatible changes, or to make them in a way that is
> > caught by the compiler.
> Ok; understand.  (I'll keep that in mind for future patching too!)  I
> have a clean solution now...
> > On the other hand adding a g_timer_continue() that doesn't reset the
> > timer to zero sounds reasonable to me.
> I have rewritten the patch.  The existing behaviour is not changed.  I
> have added code to g_timer_stop() to accumulate the total elapsed time,
> and I have added a new function called g_timer_total_elapsed() that will
> return the true elapsed time (between start-stop calls) since the last
> g_timer_reset() (instead of modifying g_timer_elapsed()).
> I also added g_timer_is_active() to return whether or not the timer is
> running.  In the process, I also added docstrings for all the functions,
> that are consistent with the API reference on the web.  I can update the
> web reference if someone tells me where the source lives.
> I have tested and verified that it works according to both the old and
> the new ways.  Is this ok?  Shall I file this in bugzilla?

Filing patches in bugzilla is the best way to make sure they don't
get lost.

Isn't it a little confusing to introduce the idea of a GTimer containing
two different times; the current elapsed time and the total elapsed

That's why I suggested g_timer_continue() ...  it seems to me to keep
model simple.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]