octave-maintainers
[Top][All Lists]
Advanced

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

Re: Thread-safe access to graphic objects - proposal


From: Driss Ghaddab
Subject: Re: Thread-safe access to graphic objects - proposal
Date: Thu, 03 Jul 2008 21:08:34 +0200
User-agent: Thunderbird 2.0.0.14 (X11/20080502)

Hello,

Maciej Gajewski wrote:
And GUI changes its properties pretty often: each time figure window
is moved or resized, it's properties should change. Then: axes are
zoomed, rotated, annotation can be added etc etc.
(...)
> This all could be made simple bu just adding locks in appropriate
> places in graphics.h /graphics.cc. Having thread-safe property access
> could allow GUI backend to simply read and modify it's properties at
> any time.

But octave thread does not need to be aware of all these changes.
I think, the GUI should only update the values when requested by octave prompt (or thread). Better, it should only send the tiny information requested, and only when requested.

If octave thread needs an info, it just communicate with the thread, and
waits until it has the information (in this case, no problem with concurrent accesses).

In my opinion the octave prompt (in octave thread) does need to do only the following things:

- request to set an object property,
- request to get an object property,
- request to execute an object method.
- install callbacks

The object being something representing a gui (or anything else).

To set an object property, there are four cases:
- octave thread can set the value, but it needs to protect from mutual access (i.e. the GUI thread may modify the value, thus the mutex); - octave thread can set the value, but it does not need to protect from mutual access (i.e. the GUI thread never modifies that value) - octave thread is not allowed to modify the value and delegates the task to the GUI thread,
- or, the property is read only and it is not allowed to modify it.

These will give a combination of four cases. For GUI, typically, it is the GUI-thread which needs to set the property.

To get an object property, similarily:
- octave thread can read the value but it must protect from mutual access (i.e. the GUI thread can modify the value, thus the mutex)
- octave thread can read the value without any worry
- octave is not allowed to modify the value : it communicates with the GUI thread and waits for a response. During the wait, the GUI thread can use octave functions, because the octave thread is waiting.




reply via email to

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