fio: make gui status update in timely fashion
authorStephen M. Cameron <stephenmcameron@gmail.com>
Fri, 24 Feb 2012 07:17:31 +0000 (08:17 +0100)
committerJens Axboe <axboe@kernel.dk>
Fri, 24 Feb 2012 07:17:31 +0000 (08:17 +0100)
Needs inexplicable special gtk/gdk magic code for some reason.
(Learned this by hard won experience on Word War vi.)

Signed-off-by: Stephen M. Cameron <stephenmcameron@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Makefile
gfio.c

index c795ea4..a127027 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -10,7 +10,7 @@ SCRIPTS = fio_generate_plots
 UNAME  := $(shell uname)
 
 GTKCFLAGS = `pkg-config gtk+-2.0 --cflags`
-GTKLDFLAGS = `pkg-config gtk+-2.0 --libs`
+GTKLDFLAGS = `pkg-config gtk+-2.0 gthread-2.0 --libs`
 
 SOURCE := gettime.c ioengines.c init.c stat.c log.c time.c filesetup.c \
                eta.c verify.c memory.c io_u.c parse.c mutex.c options.c \
diff --git a/gfio.c b/gfio.c
index f41a7ba..2d97cac 100644 (file)
--- a/gfio.c
+++ b/gfio.c
@@ -168,6 +168,14 @@ static void add_buttons(struct gui *ui,
 
 static void init_ui(int *argc, char **argv[], struct gui *ui)
 {
+       /* Magical g*thread incantation, you just need this thread stuff.
+        * Without it, the label update that happens in gfio_update_thread_status
+        * doesn't really happen in a timely fashion, you need expose events
+        */
+       if (!g_thread_supported ())
+               g_thread_init(NULL);
+       gdk_threads_init();
+
        gtk_init(argc, argv);
        
        ui->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
@@ -196,6 +204,8 @@ int main(int argc, char *argv[], char *envp[])
 
        init_ui(&argc, &argv, &ui);
 
+       gdk_threads_enter();
        gtk_main();
+       gdk_threads_leave();
        return 0;
 }