Use global variable to reference main loop instead of thread name
authorDmitry Kalyanov <Kalyanov.Dmitry@gmail.com>
Wed, 13 May 2009 11:18:59 +0000 (15:18 +0400)
committerDmitry Kalyanov <Kalyanov.Dmitry@gmail.com>
Wed, 13 May 2009 11:18:59 +0000 (15:18 +0400)
gtk/gtk.main_loop_events.lisp

index ecdb3da..d2bdb9c 100644 (file)
 (defcfun gtk-main :void)
 
 #+thread-support
+(defvar *main-thread* nil)
+
+#+thread-support
 (defun ensure-gtk-main ()
-  (unless (find "gtk main thread" (bt:all-threads) :test 'string= :key 'bt:thread-name)
-    (bt:make-thread (lambda () (gtk:gtk-main)) :name "gtk main thread")))
+  (unless *main-thread*
+    (setf *main-thread* (bt:make-thread (lambda () (gtk:gtk-main)) :name "cl-gtk2 main thread"))))
+
+#+thread-support
+(defun join-main-thread ()
+  (when *main-thread*
+    (bt:join-thread *main-thread*)))
 
 #-thread-support
 (defun ensure-gtk-main ()