From eefdecd8b9f0e9e65a713efff8b234bae9379cbd Mon Sep 17 00:00:00 2001
From: Daniel Drake <dsd@laptop.org>
Date: Sat, 6 Dec 2008 21:29:39 +0000
Subject: [PATCH] Use g_timeout_add_seconds() for power efficiency
This attempts to align second-granularity wakeups across the system,
reducing CPU wakeups a little.
I considered all timeouts of duration 1 second or greater, and moved
the non-timing-critical ones to g_timeout_add_seconds(). (Actually,
I didn't find any that I felt were timing-critical)
---
src/sugar/acme-volume-alsa.c | 2 +-
src/sugar/activity/activity.py | 4 ++--
src/sugar/eggdesktopfile.c | 4 ++--
src/sugar/graphics/alert.py | 2 +-
src/sugar/gsm-client-xsmp.c | 2 +-
src/sugar/gsm-session.c | 2 +-
6 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/sugar/acme-volume-alsa.c b/src/sugar/acme-volume-alsa.c
index c1ea5cc..42bbf4e 100644
a
|
b
|
bail: |
292 | 292 | static void |
293 | 293 | acme_volume_alsa_close (AcmeVolumeAlsa *self) |
294 | 294 | { |
295 | | self->_priv->timer_id = g_timeout_add (4000, |
| 295 | self->_priv->timer_id = g_timeout_add_seconds (4, |
296 | 296 | (GSourceFunc) acme_volume_alsa_close_real, self); |
297 | 297 | } |
298 | 298 | |
diff --git a/src/sugar/activity/activity.py b/src/sugar/activity/activity.py
index 39c2f48..be9397b 100644
a
|
b
|
class ActivityToolbar(gtk.Toolbar): |
184 | 184 | |
185 | 185 | def __title_changed_cb(self, entry): |
186 | 186 | if not self._update_title_sid: |
187 | | self._update_title_sid = gobject.timeout_add( |
188 | | 1000, self.__update_title_cb) |
| 187 | self._update_title_sid = gobject.timeout_add_seconds( |
| 188 | 1, self.__update_title_cb) |
189 | 189 | |
190 | 190 | def __update_title_cb(self): |
191 | 191 | title = self.title.get_text() |
diff --git a/src/sugar/eggdesktopfile.c b/src/sugar/eggdesktopfile.c
index ad78345..eb28b9d 100644
a
|
b
|
end_startup_notification (GdkDisplay *display, |
955 | 955 | NULL); |
956 | 956 | } |
957 | 957 | |
958 | | #define EGG_DESKTOP_FILE_SN_TIMEOUT_LENGTH (30 /* seconds */ * 1000) |
| 958 | #define EGG_DESKTOP_FILE_SN_TIMEOUT_LENGTH 30 /* seconds */ |
959 | 959 | |
960 | 960 | typedef struct { |
961 | 961 | GdkDisplay *display; |
… |
… |
set_startup_notification_timeout (GdkDisplay *display, |
985 | 985 | sn_data->display = g_object_ref (display); |
986 | 986 | sn_data->startup_id = g_strdup (startup_id); |
987 | 987 | |
988 | | g_timeout_add (EGG_DESKTOP_FILE_SN_TIMEOUT_LENGTH, |
| 988 | g_timeout_add_seconds (EGG_DESKTOP_FILE_SN_TIMEOUT_LENGTH, |
989 | 989 | startup_notification_timeout, sn_data); |
990 | 990 | } |
991 | 991 | #endif /* HAVE_GDK_X11_DISPLAY_BROADCAST_STARTUP_MESSAGE */ |
diff --git a/src/sugar/graphics/alert.py b/src/sugar/graphics/alert.py
index 6cfa0fa..2c3c4ca 100644
a
|
b
|
class TimeoutAlert(Alert): |
376 | 376 | canvas.show() |
377 | 377 | self.add_button(gtk.RESPONSE_OK, _('Continue'), canvas) |
378 | 378 | |
379 | | gobject.timeout_add(1000, self.__timeout) |
| 379 | gobject.timeout_add_seconds(1, self.__timeout) |
380 | 380 | |
381 | 381 | def __timeout(self): |
382 | 382 | self._timeout -= 1 |
diff --git a/src/sugar/gsm-client-xsmp.c b/src/sugar/gsm-client-xsmp.c
index dcacc6f..04c7de4 100644
a
|
b
|
gsm_client_xsmp_new (IceConn ice_conn) |
110 | 110 | client_iochannel_watch, xsmp); |
111 | 111 | g_io_channel_unref (channel); |
112 | 112 | |
113 | | xsmp->protocol_timeout = g_timeout_add (5000, client_protocol_timeout, xsmp); |
| 113 | xsmp->protocol_timeout = g_timeout_add_seconds (5, client_protocol_timeout, xsmp); |
114 | 114 | |
115 | 115 | set_description (xsmp); |
116 | 116 | g_debug ("New client '%s'", xsmp->description); |
diff --git a/src/sugar/gsm-session.c b/src/sugar/gsm-session.c
index b1f4f0e..0fe2fb5 100644
a
|
b
|
start_phase (GsmSession *session) |
203 | 203 | { |
204 | 204 | if (session->phase < GSM_SESSION_PHASE_APPLICATION) |
205 | 205 | { |
206 | | session->timeout = g_timeout_add (GSM_SESSION_PHASE_TIMEOUT * 1000, |
| 206 | session->timeout = g_timeout_add_seconds (GSM_SESSION_PHASE_TIMEOUT, |
207 | 207 | phase_timeout, session); |
208 | 208 | } |
209 | 209 | } |