[cells-gtk-devel] Allegro 8.0 GUI multithreading

set at tewebs.com set at tewebs.com
Tue Feb 3 01:58:26 UTC 2009


Hi!
First, I'm actually using Allegro 8.1, not 8.0, under windows xp. I'm using
cells-gtk3.
For a summary, i believe the code stalls in the main-loop function in the file
gtk-app when
(gtk-main) is called. I believe gtk-main directly calls a foreign function.

For reference, my test code is as follows:
(defpackage :test (:use :cl  :cells :cells-gtk))
(in-package :test)

(defvar *width* 300)
(defvar *height* 300)


(defmodel click-button (vbox)
  ()
  (:default-initargs

    :kids (c? (the-kids
               (mk-button 
                :width *width*
                :height *height*
                :on-clicked
                (callback (widget event data)))))))

(defmodel stay-awake-gui (gtk-app)
  ()
  (:default-initargs
      :width *width*
    :height *height*
    :kids (c? (the-kids
               (make-instance 'click-button
                 :fm-parent *parent*)))))

(defun start-button-monitor ()
     (cgtk::start-win 'stay-awake-gui))

(let ((*gtk-debug* t))
  (cgtk::with-trcs 
      (start-button-monitor)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

I'm not using the libcellsgtk dll because all the dlls i can find do not have
the gtk-adds-g-thread-supported function in them which is required. I'm using
cells-gtk3, and these dlls i find aren't for this cells-gtk version.

Bordeaux threads is supported for allegro on windows according to the Common Lisp
Directory.
I also tried a simple example, and it worked.

I tried turning debug on, but I think there is no traces between the points the
error is 
taking place. I only got:

; Foreign loading libgobject-2.0-0.dll.
; Foreign loading libglib-2.0-0.dll.
; Foreign loading libgthread-2.0-0.dll.
; Foreign loading libgdk-win32-2.0-0.dll.
; Foreign loading libgtk-win32-2.0-0.dll.

; Foreign loading C:\Program Files\clisp-2.45\Lisp
Libraries\cells-gtk3\gtk-ffi\libcellsgtk.dll
-----UTILS--RESET-------- ;;or something like this

However, using allegro's stepper, I believe this is the place where allegro 
stalls. Start-win calls start-gtk-main which in turn calls gtk-main-thread
which then calls main-loop where everything stalls.

;;in function start-gtk-main
(threads:make-thread #'(lambda () (let ((*standard-output* so)) (gtk-thread))) 
     :name "gtk-main-thread"))

;;closure surrounding start-gtk-main which includes gtk-thread function
(progn
 (let ((gtk-main-thread nil))
   (flet ((gtk-thread ()
	    (gdk-threads-register-gtk-main (threads:current-thread))
	    (setf gtk-main-thread (threads:current-thread))
	    (loop (main-loop))))


;;piece of function in which allegro stalls
;;specifically, the line
;;#-lispworks (gtk-main)
(defun main-loop ()
  "Run GTK Main until user signal quit.  Errors are caught and displayed in a
dialog, providing the user with the option to \"recklessly continue\" -- not to
be called directly"
  (unwind-protect
       (if (eql *using-thread* 'yes)
	   (loop until
		(restart-case
		    (handler-bind
		       ((gtk-continuable-error #'(lambda (condition) (invoke-restart 
'continue-from-error condition )))
			 (error #'(lambda (con) (invoke-restart 'report-error con))))
		      #-lispworks
		      (gtk-main) ;;<-----Stalls Here
		      ;; Despite a workaround for Slime (see FAQ), the gtk-main-iteration-do loop, 
		      ;; still appears to be necessary for LW. Otherwise, LW consumes 99% of CPU.
		      #+lispworks	; give slime a chance.
		      (loop 
			 (loop while (gtk-events-pending) do 
			      (gtk-main-iteration-do nil))
			 (process-wait-with-timeout .01 "GTK event loop waiting"))
		      t)



Thanks!
Seth

>Hi,
>
>Unfortunately I only have SBCL over here (linux), so here's a few
>comments off the top of my head:
>
>To understand your problem better, which platform are you on, linux or windows?
>
>Have you tried using libcellsgtk?  When you're on linux, compiling it
>is pretty straight forward, and for windows there are downloadable
>versions.  Someone here might be able to provide a compiled version if
>you give us specifics on your set up.
>
>Have you activated cells-gtk's tracing?  Have a look at gtk-app.lisp
>(I believe -- currently I am on an office machine with Win XP and no
>development tools), there's a feature like "debug" or something which
>you can use to activate tracing.  That might help, too.
>
>Furthermore, how's bordeaux-threads with allegro on your platform?  Is
>that all cleared (check the bordeaux-threads homepage).
>
>If you send a trace (preferably the cells-gtk debug output) and some
>more info on your environment, I might be able to give better advice.
>
>Thanks,
>
>Peter
>
>On Sun, Feb 1, 2009 at 3:28 PM,  set at tewebs.com> wrote:
>> I'm trying to produce a multithreaded GUI in Allegro 8.0.
>> However, once i try start-win, everything freezes. I traaced it back, and it
>> appears that it stars freezing in the main-loop function, specifically when
>> gtk-main is called. In addition, i tried to use the lispworks specific code in
>> the main-loop function marked with #+lispworks, and it still freezes.
>>
>> Notice that I am not using the libcellsgtk dll which is necessary for some
>> aspects. Is this the problem?
>>
>> Any help would be appreciated!
>> Thxs!
>>
>>
>>
>> 
>>
>> _______________________________________________
>> cells-gtk-devel site list
>> cells-gtk-devel at common-lisp.net
>> http://common-lisp.net/mailman/listinfo/cells-gtk-devel
>>


---- Msg sent via WebMail




More information about the cells-gtk-devel mailing list