Changeset ba12b44
- Timestamp:
- May 23, 2011, 8:57:46 PM (13 years ago)
- Branches:
- master, release-1.10, release-1.8, release-1.9
- Children:
- 1d21d9f
- Parents:
- 117b2ba
- git-author:
- David Benjamin <davidben@mit.edu> (03/02/11 13:47:21)
- git-committer:
- David Benjamin <davidben@mit.edu> (05/23/11 20:57:46)
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
owl.c
r117b2ba rba12b44 365 365 } 366 366 367 static gboolean sig_handler_main_thread(gpointerdata) {367 static void sig_handler_main_thread(void *data) { 368 368 int sig = GPOINTER_TO_INT(data); 369 369 … … 378 378 owl_process_input_char(in); 379 379 } 380 return FALSE;381 380 } 382 381 383 382 static void sig_handler(int sig, void *data) { 384 GMainContext *context = data;385 GSource *source;386 387 383 /* If it was an interrupt, set a flag so we can handle it earlier if 388 384 * needbe. sig_handler_main_thread will check the flag to make sure … … 392 388 } 393 389 /* Send a message to the main thread. */ 394 source = g_idle_source_new(); 395 g_source_set_priority(source, G_PRIORITY_DEFAULT); 396 g_source_set_callback(source, sig_handler_main_thread, 397 GINT_TO_POINTER(sig), NULL); 398 g_source_attach(source, context); 399 g_source_unref(source); 390 owl_select_post_task(sig_handler_main_thread, GINT_TO_POINTER(sig), NULL); 400 391 } 401 392 … … 436 427 CHECK_RESULT("sigaddset", sigaddset(&sigset, SIGHUP)); 437 428 CHECK_RESULT("sigaddset", sigaddset(&sigset, SIGINT)); 438 owl_signal_init(&sigset, sig_handler, g_main_context_default());429 owl_signal_init(&sigset, sig_handler, NULL); 439 430 } 440 431 -
select.c
r117b2ba rba12b44 2 2 3 3 static GMainLoop *loop = NULL; 4 static GMainContext *context; 4 5 static int dispatch_active = 0; 5 6 … … 307 308 void owl_select_run_loop(void) 308 309 { 309 loop = g_main_loop_new(NULL, FALSE); 310 context = g_main_context_default(); 311 loop = g_main_loop_new(context, FALSE); 310 312 g_main_loop_run(loop); 311 313 } … … 318 320 } 319 321 } 322 323 typedef struct _owl_task { /*noproto*/ 324 void (*cb)(void *); 325 void *cbdata; 326 void (*destroy_cbdata)(void *); 327 } owl_task; 328 329 static gboolean _run_task(gpointer data) 330 { 331 owl_task *t = data; 332 if (t->cb) 333 t->cb(t->cbdata); 334 return FALSE; 335 } 336 337 static void _destroy_task(void *data) 338 { 339 owl_task *t = data; 340 if (t->destroy_cbdata) 341 t->destroy_cbdata(t->cbdata); 342 g_free(t); 343 } 344 345 void owl_select_post_task(void (*cb)(void*), void *cbdata, void (*destroy_cbdata)(void*)) 346 { 347 GSource *source = g_idle_source_new(); 348 owl_task *t = g_new0(owl_task, 1); 349 t->cb = cb; 350 t->cbdata = cbdata; 351 t->destroy_cbdata = destroy_cbdata; 352 g_source_set_priority(source, G_PRIORITY_DEFAULT); 353 g_source_set_callback(source, _run_task, t, _destroy_task); 354 g_source_attach(source, context); 355 g_source_unref(source); 356 }
Note: See TracChangeset
for help on using the changeset viewer.