Changes in global.c [0792d99:219f52c]
Legend:
- Unmodified
- Added
- Removed
-
global.c
r0792d99 r219f52c 10 10 11 11 g_type_init(); 12 #if !GLIB_CHECK_VERSION(2, 31, 0)13 12 g_thread_init(NULL); 14 #endif15 13 16 14 owl_select_init(); … … 102 100 103 101 g->interrupt_count = 0; 104 #if GLIB_CHECK_VERSION(2, 31, 0)105 g_mutex_init(&g->interrupt_lock);106 #else107 102 g->interrupt_lock = g_mutex_new(); 108 #endif109 103 } 110 104 … … 905 899 } 906 900 907 static GMutex *owl_global_get_interrupt_lock(owl_global *g)908 {909 #if GLIB_CHECK_VERSION(2, 31, 0)910 return &g->interrupt_lock;911 #else912 return g->interrupt_lock;913 #endif914 }915 916 901 void owl_global_add_interrupt(owl_global *g) { 917 902 /* TODO: This can almost certainly be done with atomic 918 903 * operations. Whatever. */ 919 g_mutex_lock( owl_global_get_interrupt_lock(g));904 g_mutex_lock(g->interrupt_lock); 920 905 g->interrupt_count++; 921 g_mutex_unlock( owl_global_get_interrupt_lock(g));906 g_mutex_unlock(g->interrupt_lock); 922 907 } 923 908 924 909 bool owl_global_take_interrupt(owl_global *g) { 925 910 bool ans = false; 926 g_mutex_lock( owl_global_get_interrupt_lock(g));911 g_mutex_lock(g->interrupt_lock); 927 912 if (g->interrupt_count > 0) { 928 913 ans = true; 929 914 g->interrupt_count--; 930 915 } 931 g_mutex_unlock( owl_global_get_interrupt_lock(g));916 g_mutex_unlock(g->interrupt_lock); 932 917 return ans; 933 918 }
Note: See TracChangeset
for help on using the changeset viewer.