[cells-gtk-devel] Allegro 8.0 GUI multithreading

Peter Hildebrandt peter.hildebrandt at gmail.com
Wed Feb 4 18:43:15 UTC 2009


Hi Seth,

given the low volume and the small number of subscribers here, I think
you can feel free to hit "reply all" and thus cc the list on each of
your posts.  The cells-gtk community is pretty small (optimistic
guess:  you need two hands to count 'em all).

I might say otherwise if there was a bigger audience and 50+ mails a
day, but this way I don't think anyone minds.

If anyone here is seriously upset about deleting an occasional "thank
you" mail, please let me know, before I go on teaching wrong stuff to
people :-)

As to the problem at hand:  I'll install the Bloodshed DevCpp (see
Kenny's link) and some lisp on my office laptop on the weekend and see
how far I get.  I'll keep you posted.

Cheers,
Peter




On Wed, Feb 4, 2009 at 1:55 AM,  <set at tewebs.com> wrote:
> Thanks! I'll look forward to hearing from you.
> Yes, it does work if i don't try to use the multithreaded start-win.
>
> Just a quick question. Do I specifically send an email to the person who replied
> to me or
> do I somehow send the email to the cells-gtk-devel? I'm new to this.
>
> Thanks,
> Seth
>
> On Tue Feb  3  1:39 , Peter Hildebrandt <peter.hildebrandt at gmail.com> sent:
>
>>Hi Seth,
>>
>>thanks a lot for the comprehensive description.  I am quite busy right
>>now, but I will look into it.  This will entail me installing Allegro
>>on my win xp office machine, and as I am quite busy right now, it
>>might take a few days (possibly until the weekend) until I get round
>>to it.  Sorry about that.
>>
>>I have a hunch that it is connected to the g_thread_supported func, so
>>my first shot would be to recompile the dll on windows with the new
>>functions (since I do not have windows on my development box, I never
>>did that).  I am not a really a windows person, so I don't even know
>>which tools to use, but we'll see ...
>>
>>I also remember reading that there was some issue with gdk/gtk and
>>threading on windows in general, and that there was something special
>>to take care of -- but since I was solely on linux and writing a
>>thesis, I had other things on my mind.
>>
>>I'll get back to you in a few days.
>>
>>Cheers,
>>
>>Peter
>>
>>Btw, does it work w/o threading?
>>
>>
>>On Tue, Feb 3, 2009 at 2:58 AM,  set at tewebs.com> wrote:
>>> 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) ;;
>>>                      ;; 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
>>>
>
>
> ---- Msg sent via WebMail
>




More information about the cells-gtk-devel mailing list