diff options
author | Ben Gamari <ben@smart-cactus.org> | 2016-05-08 09:35:29 +0200 |
---|---|---|
committer | Patrick Griffis <tingping@tingping.se> | 2016-06-29 15:24:03 -0400 |
commit | 7dca22048633479e28fec8e311ae80c9f55d46b6 (patch) | |
tree | f6f53c0b017683edb56af852acf46af2e3e38c2f /src/common/hexchat.c | |
parent | 111ba3750fd16c81100de6b759103e527c2c22f7 (diff) |
Refactor timer handling
This allows us to omit the lagometer timer in the event that it is not enabled, bringing the baseline wake-up rate down to 1Hz from 2Hz, which could bring considerable power savings on mobile devices.
Diffstat (limited to 'src/common/hexchat.c')
-rw-r--r-- | src/common/hexchat.c | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/src/common/hexchat.c b/src/common/hexchat.c index 499df8b0..8da63aef 100644 --- a/src/common/hexchat.c +++ b/src/common/hexchat.c @@ -355,24 +355,24 @@ doover: } static int -hexchat_misc_checks (void) /* this gets called every 1/2 second */ +hexchat_check_dcc (void) /* this gets called every 1 second */ { - static int count = 0; - - count++; - - lagcheck_update (); /* every 500ms */ - - if (count % 2) - dcc_check_timeouts (); /* every 1 second */ + dcc_check_timeouts (); + return 1; +} - if (count >= 60) /* every 30 seconds */ - { - if (prefs.hex_gui_lagometer) - lag_check (); - count = 0; - } +/* these are only run if the lagometer is enabled */ +static int +hexchat_lag_check (void) /* this gets called every 30 seconds */ +{ + lag_check (); + return 1; +} +static int +hexchat_lag_check_update (void) /* this gets called every 0.5 seconds */ +{ + lagcheck_update (); return 1; } @@ -403,10 +403,15 @@ irc_init (session *sess) if (prefs.hex_notify_timeout) notify_tag = fe_timeout_add (prefs.hex_notify_timeout * 1000, - notify_checklist, 0); + notify_checklist, NULL); - fe_timeout_add (prefs.hex_away_timeout * 1000, away_check, 0); - fe_timeout_add (500, hexchat_misc_checks, 0); + fe_timeout_add (prefs.hex_away_timeout * 1000, away_check, NULL); + fe_timeout_add (1000, hexchat_check_dcc, NULL); + if (prefs.hex_gui_lagometer) + { + fe_timeout_add (500, hexchat_lag_check_update, NULL); + fe_timeout_add (30000, hexchat_lag_check, NULL); + } if (arg_url != NULL) { |