Changeset c675b39


Ignore:
Timestamp:
Dec 17, 2008, 3:24:25 PM (15 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
1631825
Parents:
e0096b7
git-author:
Nelson Elhage <nelhage@mit.edu> (12/15/08 21:26:36)
git-committer:
Nelson Elhage <nelhage@mit.edu> (12/17/08 15:24:25)
Message:
Give timers a destructor field.

Perl timers are going to need this in order to free the SV* callback
we're holding onto.
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • aim.c

    rb7bb454 rc675b39  
    201201  owl_function_debugmsg("owl_aim_login: connecting");
    202202
    203   g.aim_nop_timer = owl_select_add_timer(30, 30, owl_aim_send_nop, NULL);
     203  g.aim_nop_timer = owl_select_add_timer(30, 30, owl_aim_send_nop, NULL, NULL);
    204204
    205205  return(0);
     
    227227  owl_global_set_ignore_aimlogin(&g);
    228228  owl_select_add_timer(owl_global_get_aim_ignorelogin_timer(&g),
    229                        0, owl_aim_unset_ignorelogin, NULL);
     229                       0, owl_aim_unset_ignorelogin, NULL, NULL);
    230230
    231231  /* aim_ssi_setpresence(owl_global_get_aimsess(&g), 0x00000400); */
  • owl.c

    r80a465c rc675b39  
    395395
    396396
    397   owl_select_add_timer(180, 180, owl_zephyr_buddycheck_timer, NULL);
     397  owl_select_add_timer(180, 180, owl_zephyr_buddycheck_timer, NULL, NULL);
    398398
    399399  /* If we ever deprecate the mainloop hook, remove this. */
    400   owl_select_add_timer(0, 1, owl_perlconfig_mainloop, NULL);
     400  owl_select_add_timer(0, 1, owl_perlconfig_mainloop, NULL, NULL);
    401401
    402402
  • owl.h

    r58d1f8a rc675b39  
    508508  int interval;
    509509  void (*callback)(struct _owl_timer *, void *);
     510  void (*destroy)(struct _owl_timer *);
    510511  void *data;
    511512} owl_timer;
  • select.c

    r58d1f8a rc675b39  
    1111}
    1212
    13 owl_timer *owl_select_add_timer(int after, int interval, void (*cb)(struct _owl_timer *, void *), void *data)
     13owl_timer *owl_select_add_timer(int after, int interval, void (*cb)(owl_timer *, void *), void (*destroy)(owl_timer*), void *data)
    1414{
    1515  owl_timer *t = owl_malloc(sizeof(owl_timer));
     
    1919  t->interval = interval;
    2020  t->callback = cb;
     21  t->destroy = destroy;
    2122  t->data = data;
    2223
     
    3132  if (t && g_list_find(*timers, t)) {
    3233    *timers = g_list_remove(*timers, t);
     34    if(t->destroy) {
     35      t->destroy(t);
     36    }
    3337    owl_free(t);
    3438  }
     
    4246  while(*timers) {
    4347    owl_timer *t = (*timers)->data;
    44     void (*cb)(struct _owl_timer *, void *);
    45     void *data;
     48    int remove = 0;
    4649
    4750    if(t->time > now)
    4851      break;
    49 
    50     cb = t->callback;
    51     data = t->data;
    5252
    5353    /* Reschedule if appropriate */
     
    5858                                     (GCompareFunc)_owl_select_timer_cmp);
    5959    } else {
     60      remove = 1;
     61    }
     62
     63    /* Do the callback */
     64    t->callback(t, t->data);
     65    if(remove) {
    6066      owl_select_remove_timer(t);
    61       t = NULL;
    62     }
    63 
    64     /* Do the callback */
    65     cb(t, data);
     67    }
    6668  }
    6769
Note: See TracChangeset for help on using the changeset viewer.