Changeset ba12b44 for owl.c


Ignore:
Timestamp:
May 23, 2011, 8:57:46 PM (10 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, 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)
Message:
Add owl_select_post_task helper function

Honestly, the only thing you'd ever want to do to a message loop from
another thread is post a one-off task to it. Why Glib makes this so
difficult is beyond me.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • owl.c

    r117b2ba rba12b44  
    365365}
    366366
    367 static gboolean sig_handler_main_thread(gpointer data) {
     367static void sig_handler_main_thread(void *data) {
    368368  int sig = GPOINTER_TO_INT(data);
    369369
     
    378378    owl_process_input_char(in);
    379379  }
    380   return FALSE;
    381380}
    382381
    383382static void sig_handler(int sig, void *data) {
    384   GMainContext *context = data;
    385   GSource *source;
    386 
    387383  /* If it was an interrupt, set a flag so we can handle it earlier if
    388384   * needbe. sig_handler_main_thread will check the flag to make sure
     
    392388  }
    393389  /* 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);
    400391}
    401392
     
    436427  CHECK_RESULT("sigaddset", sigaddset(&sigset, SIGHUP));
    437428  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);
    439430}
    440431
Note: See TracChangeset for help on using the changeset viewer.