Add g_timer_continue(). (#98536, Tim-Philipp Müller)
authorOwen Taylor <otaylor@redhat.com>
Thu, 22 Jan 2004 19:56:28 +0000 (19:56 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Thu, 22 Jan 2004 19:56:28 +0000 (19:56 +0000)
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.

15 files changed:
ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
NEWS
configure.in
docs/reference/ChangeLog
docs/reference/glib/glib-sections.txt
docs/reference/glib/tmpl/timers.sgml
docs/reference/gobject/tmpl/objects.sgml
glib/gtimer.c
glib/gtimer.h
tests/testglib.c

index 51d891a0c33f85186b90658ba53c242ec4279ae5..ad0cd60906c96bf03b7144746c3b7a55aa572c2e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+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
index 51d891a0c33f85186b90658ba53c242ec4279ae5..ad0cd60906c96bf03b7144746c3b7a55aa572c2e 100644 (file)
@@ -1,3 +1,12 @@
+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
index 51d891a0c33f85186b90658ba53c242ec4279ae5..ad0cd60906c96bf03b7144746c3b7a55aa572c2e 100644 (file)
@@ -1,3 +1,12 @@
+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
index 51d891a0c33f85186b90658ba53c242ec4279ae5..ad0cd60906c96bf03b7144746c3b7a55aa572c2e 100644 (file)
@@ -1,3 +1,12 @@
+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
index 51d891a0c33f85186b90658ba53c242ec4279ae5..ad0cd60906c96bf03b7144746c3b7a55aa572c2e 100644 (file)
@@ -1,3 +1,12 @@
+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
index 51d891a0c33f85186b90658ba53c242ec4279ae5..ad0cd60906c96bf03b7144746c3b7a55aa572c2e 100644 (file)
@@ -1,3 +1,12 @@
+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
diff --git a/NEWS b/NEWS
index 2c129ecd5bdf03baac0e4a8ce7d8b79248a45908..e4899e7b169d65b8eacccb96bff8ce79b6e4fbad 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,21 +1,26 @@
 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
 =================================================
index b5622b2163fe868ef16d7e346f8eb3e39d998596..2af80acefd285cf909e5128e5892708dd4f4c196 100644 (file)
@@ -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)])
index 03b2eb6ae8fc6f2b40caa3a4c91bb9f2e92c0e64..5cbd26d44ea2fb51f110fe32f78977397cf3f17f 100644 (file)
@@ -1,3 +1,8 @@
+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.
index 0f27726bf8b2021c9d6eb9121b2b5e82b648a143..7fb4b71a57c2ae32b13ad94773b67265a2844a99 100644 (file)
@@ -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
index 328ca3f96a3a5c89665f5a92ae792335d3878384..5ea87151a456a637c66d123269dd5a9c13714bbf 100644 (file)
@@ -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
index 2d16e5d2cbe8d295ec2a81335ed250ceb69482e6..4c311e911b0ff4fb344af63fc59aa644aeb99bfc 100644 (file)
@@ -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
+
index cdfbb19b35cc249a240290fc78a12e289e80b298..b2f516bc4419e666641f29c64b4587d43199dd58 100644 (file)
@@ -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)
index 33e5330434f6382c982307b25c4171683bfb13c5..fc434d06aa77eed66cf656cf1ee19c6c376ad83f 100644 (file)
@@ -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);
 
index c4a8c2c45967a9b04cc90abf4e1bda9edf47de88..bc807a42214bab9f0226b2382503f574d13744a4 100644 (file)
@@ -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);