Changeset c6adf17 for functions.c


Ignore:
Timestamp:
Oct 1, 2010, 9:22:20 PM (11 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.7, release-1.8, release-1.9
Children:
afaef6e
Parents:
385cce2
git-author:
David Benjamin <davidben@mit.edu> (09/25/10 02:02:45)
git-committer:
David Benjamin <davidben@mit.edu> (10/01/10 21:22:20)
Message:
Track names along with timers, add :show timers

This will help people with BarnOwls eating CPU to diagnose timer leaks.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    r118c919 rc6adf17  
    9090  owl_function_popless_fmtext(&fm);
    9191  owl_list_cleanup(&l, owl_free);
     92  owl_fmtext_cleanup(&fm);
     93}
     94
     95static void _owl_function_timer_append_fmtext(gpointer data, gpointer user_data) {
     96  owl_fmtext *fm = user_data;
     97  owl_timer *timer = data;
     98  char *str = owl_sprintf("- %s: in %d seconds",
     99                          timer->name ? timer->name : "(unnamed)",
     100                          timer->time - time(NULL));
     101  owl_fmtext_append_normal(fm, str);
     102  owl_free(str);
     103  if (timer->interval) {
     104    str = owl_sprintf(", repeat every %d seconds", timer->interval);
     105    owl_fmtext_append_normal(fm, str);
     106    owl_free(str);
     107  }
     108  owl_fmtext_append_normal(fm, "\n");
     109}
     110
     111void owl_function_show_timers(void) {
     112  owl_fmtext fm;
     113  GList **timers;
     114
     115  owl_fmtext_init_null(&fm);
     116  owl_fmtext_append_bold(&fm, "Active timers:\n");
     117
     118  timers = owl_global_get_timerlist(&g);
     119  g_list_foreach(*timers, _owl_function_timer_append_fmtext, &fm);
     120
     121  owl_function_popless_fmtext(&fm);
    92122  owl_fmtext_cleanup(&fm);
    93123}
Note: See TracChangeset for help on using the changeset viewer.