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)
This commit is contained in:
Daniel Drake 2008-12-06 21:29:39 +00:00
parent 96da9d490e
commit 2937a09ead
6 changed files with 8 additions and 8 deletions

View File

@ -292,7 +292,7 @@ bail:
static void static void
acme_volume_alsa_close (AcmeVolumeAlsa *self) acme_volume_alsa_close (AcmeVolumeAlsa *self)
{ {
self->_priv->timer_id = g_timeout_add (4000, self->_priv->timer_id = g_timeout_add_seconds (4,
(GSourceFunc) acme_volume_alsa_close_real, self); (GSourceFunc) acme_volume_alsa_close_real, self);
} }

View File

@ -184,8 +184,8 @@ class ActivityToolbar(gtk.Toolbar):
def __title_changed_cb(self, entry): def __title_changed_cb(self, entry):
if not self._update_title_sid: if not self._update_title_sid:
self._update_title_sid = gobject.timeout_add( self._update_title_sid = gobject.timeout_add_seconds(
1000, self.__update_title_cb) 1, self.__update_title_cb)
def __update_title_cb(self): def __update_title_cb(self):
title = self.title.get_text() title = self.title.get_text()

View File

@ -955,7 +955,7 @@ end_startup_notification (GdkDisplay *display,
NULL); NULL);
} }
#define EGG_DESKTOP_FILE_SN_TIMEOUT_LENGTH (30 /* seconds */ * 1000) #define EGG_DESKTOP_FILE_SN_TIMEOUT_LENGTH 30 /* seconds */
typedef struct { typedef struct {
GdkDisplay *display; GdkDisplay *display;
@ -985,7 +985,7 @@ set_startup_notification_timeout (GdkDisplay *display,
sn_data->display = g_object_ref (display); sn_data->display = g_object_ref (display);
sn_data->startup_id = g_strdup (startup_id); sn_data->startup_id = g_strdup (startup_id);
g_timeout_add (EGG_DESKTOP_FILE_SN_TIMEOUT_LENGTH, g_timeout_add_seconds (EGG_DESKTOP_FILE_SN_TIMEOUT_LENGTH,
startup_notification_timeout, sn_data); startup_notification_timeout, sn_data);
} }
#endif /* HAVE_GDK_X11_DISPLAY_BROADCAST_STARTUP_MESSAGE */ #endif /* HAVE_GDK_X11_DISPLAY_BROADCAST_STARTUP_MESSAGE */

View File

@ -376,7 +376,7 @@ class TimeoutAlert(Alert):
canvas.show() canvas.show()
self.add_button(gtk.RESPONSE_OK, _('Continue'), canvas) self.add_button(gtk.RESPONSE_OK, _('Continue'), canvas)
gobject.timeout_add(1000, self.__timeout) gobject.timeout_add_seconds(1, self.__timeout)
def __timeout(self): def __timeout(self):
self._timeout -= 1 self._timeout -= 1

View File

@ -110,7 +110,7 @@ gsm_client_xsmp_new (IceConn ice_conn)
client_iochannel_watch, xsmp); client_iochannel_watch, xsmp);
g_io_channel_unref (channel); g_io_channel_unref (channel);
xsmp->protocol_timeout = g_timeout_add (5000, client_protocol_timeout, xsmp); xsmp->protocol_timeout = g_timeout_add_seconds (5, client_protocol_timeout, xsmp);
set_description (xsmp); set_description (xsmp);
g_debug ("New client '%s'", xsmp->description); g_debug ("New client '%s'", xsmp->description);

View File

@ -203,7 +203,7 @@ start_phase (GsmSession *session)
{ {
if (session->phase < GSM_SESSION_PHASE_APPLICATION) if (session->phase < GSM_SESSION_PHASE_APPLICATION)
{ {
session->timeout = g_timeout_add (GSM_SESSION_PHASE_TIMEOUT * 1000, session->timeout = g_timeout_add_seconds (GSM_SESSION_PHASE_TIMEOUT,
phase_timeout, session); phase_timeout, session);
} }
} }