Changeset a902ebb
- Timestamp:
- Oct 29, 2012, 11:19:40 PM (12 years ago)
- Parents:
- 9b3167b (diff), 0792d99 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
global.c
r219f52c r0792d99 10 10 11 11 g_type_init(); 12 #if !GLIB_CHECK_VERSION(2, 31, 0) 12 13 g_thread_init(NULL); 14 #endif 13 15 14 16 owl_select_init(); … … 100 102 101 103 g->interrupt_count = 0; 104 #if GLIB_CHECK_VERSION(2, 31, 0) 105 g_mutex_init(&g->interrupt_lock); 106 #else 102 107 g->interrupt_lock = g_mutex_new(); 108 #endif 103 109 } 104 110 … … 899 905 } 900 906 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 #else 912 return g->interrupt_lock; 913 #endif 914 } 915 901 916 void owl_global_add_interrupt(owl_global *g) { 902 917 /* TODO: This can almost certainly be done with atomic 903 918 * operations. Whatever. */ 904 g_mutex_lock( g->interrupt_lock);919 g_mutex_lock(owl_global_get_interrupt_lock(g)); 905 920 g->interrupt_count++; 906 g_mutex_unlock( g->interrupt_lock);921 g_mutex_unlock(owl_global_get_interrupt_lock(g)); 907 922 } 908 923 909 924 bool owl_global_take_interrupt(owl_global *g) { 910 925 bool ans = false; 911 g_mutex_lock( g->interrupt_lock);926 g_mutex_lock(owl_global_get_interrupt_lock(g)); 912 927 if (g->interrupt_count > 0) { 913 928 ans = true; 914 929 g->interrupt_count--; 915 930 } 916 g_mutex_unlock( g->interrupt_lock);931 g_mutex_unlock(owl_global_get_interrupt_lock(g)); 917 932 return ans; 918 933 } -
logging.c
r0a9ffc5 r0792d99 436 436 void owl_log_init(void) 437 437 { 438 log_context = g_main_context_new(); 439 #if GLIB_CHECK_VERSION(2, 31, 0) 440 logging_thread = g_thread_new("logging", 441 owl_log_thread_func, 442 NULL); 443 #else 438 444 GError *error = NULL; 439 log_context = g_main_context_new();440 445 logging_thread = g_thread_create(owl_log_thread_func, 441 446 NULL, … … 448 453 exit(1); 449 454 } 455 #endif 450 456 451 457 } -
owl.h
r219f52c rcb124fc6 596 596 char *kill_buffer; 597 597 int interrupt_count; 598 #if GLIB_CHECK_VERSION(2, 31, 0) 599 GMutex interrupt_lock; 600 #else 598 601 GMutex *interrupt_lock; 602 #endif 599 603 } owl_global; 600 604
Note: See TracChangeset
for help on using the changeset viewer.