[beast/devel: 1/5] bsescm: speedup bse_scm_context_iteration by proper mainloop integration
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast/devel: 1/5] bsescm: speedup bse_scm_context_iteration by proper mainloop integration
- Date: Sun, 16 Dec 2012 02:19:47 +0000 (UTC)
commit 3aeeeabbe10458f1c8a589e66ba287db2ec00962
Author: Stefan Westerfeld <stefan space twc de>
Date: Wed Feb 23 00:22:28 2011 +0100
bsescm: speedup bse_scm_context_iteration by proper mainloop integration
shell/bsescm.cc | 14 ++++++++++++++
shell/bsescminterp.cc | 3 +--
2 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/shell/bsescm.cc b/shell/bsescm.cc
index 70102d2..a159d76 100644
--- a/shell/bsescm.cc
+++ b/shell/bsescm.cc
@@ -60,11 +60,18 @@ port_closed (SfiComPort *port,
exit (BSE_EXIT_STATUS);
}
+static void
+dummy_dispatch (void *foo)
+{
+ // nothing to do
+}
+
int
main (int argc,
char *argv[])
{
const gchar *env_str;
+ GSource *source;
sfi_init (&argc, &argv, "BSESCM", NULL);
bse_init_textdomain_only();
@@ -108,6 +115,13 @@ main (int argc,
/* now that the BSE thread runs, drop scheduling priorities if we have any */
setpriority (PRIO_PROCESS, getpid(), 0);
+ /* setup main context to be able to wait for events from bse in bse_scm_context_iteration */
+ sfi_thread_set_wakeup ((BirnetThreadWakeup) g_main_context_wakeup, g_main_context_default(), NULL);
+ source = g_source_simple (G_PRIORITY_DEFAULT, (GSourcePending) sfi_glue_context_pending, dummy_dispatch,
+ NULL, NULL, NULL);
+ g_source_attach (source, NULL);
+ g_source_unref (source);
+
gh_enter (argc, argv, gh_main);
return 0;
diff --git a/shell/bsescminterp.cc b/shell/bsescminterp.cc
index a62d477..4d18215 100644
--- a/shell/bsescminterp.cc
+++ b/shell/bsescminterp.cc
@@ -1092,11 +1092,10 @@ bse_scm_context_iteration (SCM s_may_block)
sfi_glue_context_dispatch ();
else if (gh_scm2bool (s_may_block))
{
- /* FIXME: we need a real poll() based wait implementation here */
do
{
BSE_SCM_ALLOW_INTS ();
- g_usleep (250 * 1000);
+ g_main_context_iteration (g_main_context_default(), TRUE);
BSE_SCM_DEFER_INTS ();
}
while (!sfi_glue_context_pending ());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]