Peter Denno | 4 Dec 2007 17:10
Favicon

Re: start-app and multithreading?

On Tuesday 04 December 2007 09:57, Peter Hildebrandt wrote:
> Peter,
>
> thanks for your reply.  I've made some progress, but before
> suggesting a patch I'd like to verify a few internals.
>
> The GTK/GDK doc says, that you're fine as long as you use gdk/gtk
> only in callback functions such as on-click-handlers.  These
> callbacks are apparently run within the lock we supply for
> gtk-main.  However in "Idles, timeouts, and input functions" [1]
> you'd need to sorround calls to gtk/gdk with the equivalent of
> with-gdk-threads.

I see that the entire main loop in gtk-app is surrounded in 
with-gdk-threads, but nothing on a finer grain. Is this the problem?

> [1]
> http://www.gnu.org/software/guile-gnome/docs/gdk/html/Threads.html

I recall reading this page after struggling with the behavior in the 
Win32 port of my program. 

It has been about a year since I've worked with cells-gtk (Not that I 
don't like it, or have given up on it.  I'm just busy with some 
server stuff and hunchentoot). 

> Now I have poked around the code for a while, and did not find any
> of those.  Does cells-gtk use "Idles, timeouts, and input
> functions"?  If yes, where?

(Continue reading)

Peter Hildebrandt | 4 Dec 2007 18:45
Picon

Re: start-app and multithreading?


Peter,

thanks for your pointers.  Just to clarify things, I am working with the  
latest SBCL on linux (ubuntu 7.10, gtk 2.2) mostly from slime.  I do not  
have other environments around for testing.

> I see that the entire main loop in gtk-app is surrounded in
> with-gdk-threads, but nothing on a finer grain. Is this the problem?

Actually from what I understand this is perfectly fine (and most C sample  
code on the net seems to do the same).  During normal use, the thread will  
spend its time within gtk-main, and gtk-main apparently releases the lock  
on idle and reacquires it when calling a callback.  So this is fine.

> It has been about a year since I've worked with cells-gtk (Not that I
> don't like it, or have given up on it.  I'm just busy with some
> server stuff and hunchentoot).

That's good to hear.  Especially now that threading appears to work (at  
least with SBCL in linux), it makes a great development environment for  
local GUI apps.  Just another example:

;; first create an empty window
(make-be 'window :title "Some Window" :kids (c-in nil))
;; the window shows up and is empty

;; next make a button and see what happens
(setf (kids *) (list (mk-button :label "click me" :on-clicked (callback (w  
e d) (print 'clicked)))))
(Continue reading)


Gmane