[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] Gtk event loop

From: Gwenael Casaccio
Subject: [Help-smalltalk] Gtk event loop
Date: Thu, 11 Feb 2010 10:47:17 +0100


Right now the gtk event look works like this :

call gtk_main

[ handleEvents. true ] whileTrue: [ Processor yield ]

first problem the gtk_main function blocks the smalltalk processes.
second problem if we enter in the event handling loop this is an active
waiting it burns your CPU :P.

As we can see the Gtk event loop doesn't feet at all with Smalltalk.
since in the first case Smalltalk processes are not handled. In the
second case the Smalltalk processes are handled but with an high cpu

So here is my proposal for a new Gtk event handling :

  first we create a c thread with the gtk_main function, when there is
an event the c function : invoke_smalltalk_closure will be called signal
a Smalltalk semaphore and lock a C muted. 

  in Smalltalk inside an infinite loop we wait for an event with a
Semaphore, when there is an event we get the signal get the event and
handle it : 
  - if it works well the result is sent to a C Function and signal the C
  - if there is an exception launch a debugger and launch a new gtk_main
inner loop

  Some events can occurs if we are not inside the gtk_main loop so we
handle it like this : in the c function : invoke_smalltalk_closure we
check if the thread is the main thread if yes we call Gtk innerEvent

  Right now that works well (for example I can launch iLiad without any
problem) I should fix the gtk_dialog_run because this function launch an
inner loop outside the same thread that the main gtk_loop; the two loops
are locked :D.

  If you have a better idea, cleaner approach any comments, remarks are
welcome !


reply via email to

[Prev in Thread] Current Thread [Next in Thread]