help-smalltalk
[Top][All Lists]
Advanced

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

[Help-smalltalk] GTK main loop


From: Gwenael Casaccio
Subject: [Help-smalltalk] GTK main loop
Date: Thu, 04 Aug 2011 16:21:17 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110617 Lightning/1.0b2 Thunderbird/3.1.11

Hi,

  I've tried to hack a bit the Gtk main loop, with the idea to
add a way to stop processes when pressing a key. The problem
with the current loop, when the infinite loop is running, a nested loop should be launched because no others events are executed.

  I've changed the loop also because polling events with the current one
is sometimes so slow. So the new loop is an infinite loop that is executed all the 8 milliseconds (5% of CPU time with top). If there is a process I create a new process and handle the events, but if it takes too much time (with another delay) I create another nested event loop.

The nested process is never created, if you have any ideas, may be there is a priority problem and the processes should be high priority ?
Or simply a bad design or idea :s

GtkLoop := [ | delay |
 delay := Delay forMilliseconds: 8.

 [
   GTK.Gtk eventsPending ifTrue: [  [ | timeout |
     timeout := Delay forMilliseconds: 500.
timeout gtkValue: [ GTK.Gtk mainIterationDo: false ] onTimeoutDo: [ GtkLoop forkAt: Processor timingPriority. stderr nextPutAll: 'here'; flush. ] ] fork ].
 delay
  wait; reset ] repeat
].
VisualGST open.
GtkLoop fork.

Gwen



reply via email to

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