Commit 7ace4553 authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Add g_timer_continue(). (#98536, Tim-Philipp Müller)

Thu Jan 22 13:55:44 2004  Owen Taylor  <otaylor@redhat.com>

        * glib/gtimer.c: Add g_timer_continue().
        (#98536, Tim-Philipp Müller)

        * configure.in: Version 2.3.2, interface age 0.

        * NEWS: tweak, finish.
parent 6726db0a
Thu Jan 22 13:55:44 2004 Owen Taylor <otaylor@redhat.com>
* glib/gtimer.c: Add g_timer_continue().
(#98536, Tim-Philipp Müller)
* configure.in: Version 2.3.2, interface age 0.
* NEWS: tweak, finish.
Thu Jan 22 20:50:55 2004 Matthias Clasen <maclas@gmx.de>
* glib/gutils.c (g_get_any_init): Protect against
......
Thu Jan 22 13:55:44 2004 Owen Taylor <otaylor@redhat.com>
* glib/gtimer.c: Add g_timer_continue().
(#98536, Tim-Philipp Müller)
* configure.in: Version 2.3.2, interface age 0.
* NEWS: tweak, finish.
Thu Jan 22 20:50:55 2004 Matthias Clasen <maclas@gmx.de>
* glib/gutils.c (g_get_any_init): Protect against
......
Thu Jan 22 13:55:44 2004 Owen Taylor <otaylor@redhat.com>
* glib/gtimer.c: Add g_timer_continue().
(#98536, Tim-Philipp Müller)
* configure.in: Version 2.3.2, interface age 0.
* NEWS: tweak, finish.
Thu Jan 22 20:50:55 2004 Matthias Clasen <maclas@gmx.de>
* glib/gutils.c (g_get_any_init): Protect against
......
Thu Jan 22 13:55:44 2004 Owen Taylor <otaylor@redhat.com>
* glib/gtimer.c: Add g_timer_continue().
(#98536, Tim-Philipp Müller)
* configure.in: Version 2.3.2, interface age 0.
* NEWS: tweak, finish.
Thu Jan 22 20:50:55 2004 Matthias Clasen <maclas@gmx.de>
* glib/gutils.c (g_get_any_init): Protect against
......
Thu Jan 22 13:55:44 2004 Owen Taylor <otaylor@redhat.com>
* glib/gtimer.c: Add g_timer_continue().
(#98536, Tim-Philipp Müller)
* configure.in: Version 2.3.2, interface age 0.
* NEWS: tweak, finish.
Thu Jan 22 20:50:55 2004 Matthias Clasen <maclas@gmx.de>
* glib/gutils.c (g_get_any_init): Protect against
......
Thu Jan 22 13:55:44 2004 Owen Taylor <otaylor@redhat.com>
* glib/gtimer.c: Add g_timer_continue().
(#98536, Tim-Philipp Müller)
* configure.in: Version 2.3.2, interface age 0.
* NEWS: tweak, finish.
Thu Jan 22 20:50:55 2004 Matthias Clasen <maclas@gmx.de>
* glib/gutils.c (g_get_any_init): Protect against
......
Overview of Changes from GLib 2.3.1 to GLib 2.3.2
=================================================
* Add G_MAXSIZE. [Manish Singh]
* Add G_MAXSIZE. [Manish Singh]
* Add g_rand_new_with_seed_array(), g_rand_set_seed_array(),
implementing the init-by-array functionality of the
original mersenne twister. [George Lebl]
original mersenne twister. Add g_rand_copy(). Improve seeding.
[George Lebl]
* Add a lowercase_name option to glib-mkenums. [Murray Cumming]
* Add g_ptr_array_foreach(). [Matthias Clasen]
* Fix a threadsafety issue in mem chunks. [Matthias]
* Add g_timer_continue(). [Tim-Philipp Müller]
* Fix a threadsafety issue in mem chunks. [Matthias, Balazs Scheidler]
* Fix g_filename_{to,from}_utf8() on Win32 and improve
g_file_test() there too [Hans Breuer]
* Add a boxed type for NULL-terminated string arrays. [Matthias]
* Add G_DEFINE_TYPE() plus variants to ease the constuction
of GObject boilerplate code. [Tim Janik]
* Support & in password GECOS field [Matthias, Soeren Boll Overgaard]
* Documentation improvements [Matthias, Manish]
* Misc bug fixes [Manish, Matthias, Owen Taylor]
* Updated translations (ar,nn,fa,de,mn,no,ga)
* Win32 build fixes [Hans]
* Misc bug fixes [Damien Carbery, Matthias, Manish, Olivier Poncet,
Zack Rusin]
* Updated translations (ar,de,fa,ga,mn,nn,no,sq)
Overview of Changes from GLib 2.3.0 to GLib-2.3.1
=================================================
......
......@@ -27,7 +27,7 @@ m4_include(m4macros/glib-gettext.m4)dnl
#
m4_define([glib_major_version], [2])
m4_define([glib_minor_version], [3])
m4_define([glib_micro_version], [1])
m4_define([glib_micro_version], [2])
m4_define([glib_interface_age], [0])
m4_define([glib_binary_age],
[m4_eval(100 * glib_minor_version + glib_micro_version)])
......
Thu Jan 22 14:51:19 2004 Owen Taylor <otaylor@redhat.com>
* glib/glib-sections.txt glib/tmpl/timers.sgml: Document
g_timer_continue. (Tim-Philipp Müller)
Sun Jan 11 01:25:44 2004 Matthias Clasen <maclas@gmx.de>
* gobject/tmpl/gtype.sgml: Improve docs for G_DEFINE_TYPE_* macros.
......
......@@ -829,6 +829,7 @@ GTimer
g_timer_new
g_timer_start
g_timer_stop
g_timer_continue
g_timer_elapsed
g_timer_reset
g_timer_destroy
......
......@@ -52,6 +52,15 @@ between this end time and the start time.
@timer: a #GTimer.
<!-- ##### FUNCTION g_timer_continue ##### -->
<para>
Resumes a timer that has previously been stopped with g_timer_stop().
g_timer_stop() must be called before using this function.
</para>
@timer: a #GTimer.
@Since: 2.4
<!-- ##### FUNCTION g_timer_elapsed ##### -->
<para>
If @timer has been started but not stopped, obtains the time since the timer was
......
......@@ -21,17 +21,6 @@ to the #GObject implementation and should never be accessed directly.
</para>
<!-- ##### SIGNAL GObject::notify ##### -->
<para>
The notify signal is emitted on an object when one of its properties
has been changed. Note that getting this signal doesn't guarantee that the
value of the property has actually changed, it may also be emitted when
the setter for the property is called to reinstate the previous value.
</para>
@gobject: the object which received the signal.
@pspec: the #GParamSpec of the property which changed
<!-- ##### STRUCT GObjectClass ##### -->
<para>
The class structure for the <structname>GObject</structname> type.
......@@ -866,3 +855,14 @@ properties in set_property() and get_property() implementations.
@pspec: the #GParamSpec of the property
<!-- ##### SIGNAL GObject::notify ##### -->
<para>
The notify signal is emitted on an object when one of its properties
has been changed. Note that getting this signal doesn't guarantee that the
value of the property has actually changed, it may also be emitted when
the setter for the property is called to reinstate the previous value.
</para>
@gobject: the object which received the signal.
@pspec: the #GParamSpec of the property which changed
......@@ -118,6 +118,58 @@ g_timer_reset (GTimer *timer)
GETTIME (timer->start);
}
void
g_timer_continue (GTimer *timer)
{
#ifdef G_OS_WIN32
DWORD elapsed;
#else
struct timeval elapsed;
#endif /* G_OS_WIN32 */
g_return_if_fail (timer != NULL);
g_return_if_fail (timer->active == FALSE);
/* Get elapsed time and reset timer start time
* to the current time minus the previously
* elapsed interval.
*/
#ifdef G_OS_WIN32
elapsed = timer->end - timer->start;
GETTIME (timer->start);
timer->start -= elapsed;
#else /* !G_OS_WIN32 */
if (timer->start.tv_usec > timer->end.tv_usec)
{
timer->end.tv_usec += G_USEC_PER_SEC;
timer->end.tv_sec--;
}
elapsed.tv_usec = timer->end.tv_usec - timer->start.tv_usec;
elapsed.tv_sec = timer->end.tv_sec - timer->start.tv_sec;
GETTIME (timer->start);
if (timer->start.tv_usec < elapsed.tv_usec)
{
timer->start.tv_usec += G_USEC_PER_SEC;
timer->start.tv_sec--;
}
timer->start.tv_usec -= elapsed.tv_usec;
timer->start.tv_sec -= elapsed.tv_sec;
#endif /* !G_OS_WIN32 */
timer->active = TRUE;
}
gdouble
g_timer_elapsed (GTimer *timer,
gulong *microseconds)
......
......@@ -44,6 +44,7 @@ void g_timer_destroy (GTimer *timer);
void g_timer_start (GTimer *timer);
void g_timer_stop (GTimer *timer);
void g_timer_reset (GTimer *timer);
void g_timer_continue (GTimer *timer);
gdouble g_timer_elapsed (GTimer *timer,
gulong *microseconds);
......
......@@ -316,7 +316,7 @@ main (int argc,
GHashTable *hash_table;
GMemChunk *mem_chunk;
GStringChunk *string_chunk;
GTimer *timer;
GTimer *timer, *timer2;
gint nums[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
gint morenums[10] = { 8, 9, 7, 0, 3, 2, 5, 1, 4, 6};
gchar *string;
......@@ -946,6 +946,56 @@ main (int argc,
g_print ("ok\n");
g_print ("checking g_timer_continue...\n");
timer2 = g_timer_new ();
g_print ("\trun for 1 second...\n");
timer = g_timer_new();
g_usleep(G_USEC_PER_SEC); /* run timer for 1 second */
g_timer_stop(timer);
g_print ("\tstop for 1 second...\n");
g_usleep(G_USEC_PER_SEC); /* wait for 1 second */
g_print ("\trun for 2 seconds...\n");
g_timer_continue(timer);
g_usleep(2*G_USEC_PER_SEC); /* run timer for 2 seconds */
g_timer_stop(timer);
g_print ("\tstop for 1.5 seconds...\n");
g_usleep((3*G_USEC_PER_SEC)/2); /* wait for 1.5 seconds */
g_print ("\trun for 0.2 seconds...\n");
g_timer_continue(timer);
g_usleep(G_USEC_PER_SEC/5); /* run timer for 0.2 seconds */
g_timer_stop(timer);
g_print ("\tstop for 4 seconds...\n");
g_usleep(4*G_USEC_PER_SEC); /* wait for 4 seconds */
g_print ("\trun for 5.8 seconds...\n");
g_timer_continue(timer);
g_usleep((29*G_USEC_PER_SEC)/5); /* run timer for 5.8 seconds */
g_timer_stop(timer);
g_print ("\t=> total elapsed = %.2f seconds (should be: 9.00 seconds)\n\n", g_timer_elapsed(timer, NULL));
if (g_timer_elapsed(timer, NULL) > 8.8 && g_timer_elapsed(timer, NULL) < 9.2)
g_print ("g_timer_continue ... ok\n\n");
else
g_print ("g_timer_continue ... ***** FAILED *****\n\n");
g_timer_stop(timer2);
if (g_timer_elapsed(timer2, NULL) > (8.8+6.5) && g_timer_elapsed(timer2, NULL) < (9.2+6.5))
g_print ("timer2 ... ok\n\n");
else
g_print ("timer2 ... ***** FAILED *****\n\n");
g_timer_destroy(timer);
g_timer_destroy(timer2);
g_print ("checking g_ascii_strcasecmp...");
g_assert (g_ascii_strcasecmp ("FroboZZ", "frobozz") == 0);
g_assert (g_ascii_strcasecmp ("frobozz", "frobozz") == 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment