octave-maintainers
[Top][All Lists]
Advanced

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

Re: using timers in the GUI


From: Torsten
Subject: Re: using timers in the GUI
Date: Mon, 18 Feb 2013 19:45:46 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130106 Thunderbird/17.0.2

On 18.02.2013 19:03, Jacob Dawid wrote:
>> Yeah, I don't understand the point of the timer either.  Wouldn't it
>> be sufficient to just perform the update when the Octave interpreter
>> is at points where it is safe to perform updates?  For example, in the
>> readline callback when Octave is waiting for input and perhaps some
>> other select locations.  Jacob, could you comment about why you chose
>> to use a timer for this purpose?
> 
> That's pretty complicated.
> 
> As far as I recall, the problem was that Qt's model/view mechanism is
> not - different from what I initially supposed - threadsafe. The
> updating of the model has to be done from within the Qt thread. As I
> experienced crashes because of that, I sequenced the access to a
> specific "intermediate" memory by semaphores (basically just a
> simplified version of a symbol list). The octave symbol table is queried
> and the intermediate memory updated whenever the interpreter is ready
> and the intermediate memory is *not read* by the Qt thread (otherwise it
> would wait for the Qt thread to finish its job). At times, where the
> octave interpreter is not accessing the intermediate memory (ie.
> writing), the Qt thread periodically updates the model based on the
> intermediate memory. Since there is no guarantee that the procedure
> invoked by the timer will be finished within an interval, the timer is a
> single shot timer. It will only fire once, then the timer is restarted
> by the procedure when the model has been fully updated. That guarantees
> idle times between updates.
> 
> 

In order to make the updating work within mxe-octave, I changed the
timer setup with changeset
http://hg.savannah.gnu.org/hgweb/octave/rev/0486a29d780f

Since the timer can not be started in the callback function, the timer
was changed into a periodic one and instead, there is a flag for
enabling and disabling the update. When the timer finishes, the update
event is fired only if updates are enabled. With firing the event,
subsequent updates are disabled (by ignoring the timer) and re-enabled
at the end of the callback function (where the single shot timer was
restarted by now).

Torsten



reply via email to

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