Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • global.c

    r219f52c r0792d99  
    1010
    1111  g_type_init();
     12#if !GLIB_CHECK_VERSION(2, 31, 0)
    1213  g_thread_init(NULL);
     14#endif
    1315
    1416  owl_select_init();
     
    100102
    101103  g->interrupt_count = 0;
     104#if GLIB_CHECK_VERSION(2, 31, 0)
     105  g_mutex_init(&g->interrupt_lock);
     106#else
    102107  g->interrupt_lock = g_mutex_new();
     108#endif
    103109}
    104110
     
    899905}
    900906
     907static GMutex *owl_global_get_interrupt_lock(owl_global *g)
     908{
     909#if GLIB_CHECK_VERSION(2, 31, 0)
     910  return &g->interrupt_lock;
     911#else
     912  return g->interrupt_lock;
     913#endif
     914}
     915
    901916void owl_global_add_interrupt(owl_global *g) {
    902917  /* TODO: This can almost certainly be done with atomic
    903918   * operations. Whatever. */
    904   g_mutex_lock(g->interrupt_lock);
     919  g_mutex_lock(owl_global_get_interrupt_lock(g));
    905920  g->interrupt_count++;
    906   g_mutex_unlock(g->interrupt_lock);
     921  g_mutex_unlock(owl_global_get_interrupt_lock(g));
    907922}
    908923
    909924bool owl_global_take_interrupt(owl_global *g) {
    910925  bool ans = false;
    911   g_mutex_lock(g->interrupt_lock);
     926  g_mutex_lock(owl_global_get_interrupt_lock(g));
    912927  if (g->interrupt_count > 0) {
    913928    ans = true;
    914929    g->interrupt_count--;
    915930  }
    916   g_mutex_unlock(g->interrupt_lock);
     931  g_mutex_unlock(owl_global_get_interrupt_lock(g));
    917932  return ans;
    918933}
Note: See TracChangeset for help on using the changeset viewer.