[glib] GPeriodic: allow unblock time to be passed in
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] GPeriodic: allow unblock time to be passed in
- Date: Wed, 27 Oct 2010 13:23:19 +0000 (UTC)
commit f7a918dcb9fac00c7904b63452a59496594369aa
Author: Ryan Lortie <desrt desrt ca>
Date: Fri Oct 22 19:43:11 2010 +0200
GPeriodic: allow unblock time to be passed in
gio/gperiodic.c | 22 ++++++++++++++++++++--
gio/gperiodic.h | 3 ++-
2 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/gio/gperiodic.c b/gio/gperiodic.c
index 3eb6983..1e96f60 100644
--- a/gio/gperiodic.c
+++ b/gio/gperiodic.c
@@ -397,6 +397,7 @@ g_periodic_block (GPeriodic *periodic)
/**
* g_periodic_unblock:
* @periodic: a #GPeriodic clock
+ * @unblock_time: the unblock time, or %NULL
*
* Reverses the effect of a previous call to g_periodic_block().
*
@@ -404,13 +405,18 @@ g_periodic_block (GPeriodic *periodic)
* run. The repair signal may also be run if the clock is marked as
* damaged.
*
+ * @unblock_time is the monotonic time, as per g_get_monotonic_time(),
+ * at which the event causing the unblock occured. If it is %NULL then
+ * g_get_monotonic_time() is called internally.
+ *
* This function may not be called from handlers of any signal emitted
* by @periodic.
*
* Since: 2.28
**/
void
-g_periodic_unblock (GPeriodic *periodic)
+g_periodic_unblock (GPeriodic *periodic,
+ const GTimeSpec *unblock_time)
{
g_return_if_fail (G_IS_PERIODIC (periodic));
g_return_if_fail (!periodic->in_repair);
@@ -419,7 +425,19 @@ g_periodic_unblock (GPeriodic *periodic)
if (--periodic->blocked)
{
- periodic->last_run = g_periodic_get_microticks (periodic);
+ GTimeSpec now;
+
+ if (unblock_time == NULL)
+ {
+ g_get_monotonic_time (&now);
+ unblock_time = &now;
+ }
+
+ periodic->last_run = unblock_time->tv_sec;
+ periodic->last_run *= 1000000;
+ periodic->last_run += unblock_time->tv_nsec / 1000;
+ periodic->last_run *= periodic->hz;
+
g_periodic_run (periodic);
}
}
diff --git a/gio/gperiodic.h b/gio/gperiodic.h
index dd3fec2..636de3a 100644
--- a/gio/gperiodic.h
+++ b/gio/gperiodic.h
@@ -57,7 +57,8 @@ void g_periodic_remove (GPeriod
guint tag);
void g_periodic_block (GPeriodic *periodic);
-void g_periodic_unblock (GPeriodic *periodic);
+void g_periodic_unblock (GPeriodic *periodic,
+ const GTimeSpec *unblock_time);
void g_periodic_damaged (GPeriodic *periodic,
GPeriodicRepairFunc callback,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]