[Sugar-devel] Is there a way to purposefully do synchronous GUI updates?
Ajay Garg
ajay at activitycentral.com
Tue Aug 21 02:03:55 EDT 2012
Thanks James for the reply.
On Tue, Aug 21, 2012 at 3:47 AM, James Cameron <quozl at laptop.org> wrote:
> On Tue, Aug 21, 2012 at 12:11:13AM +0530, Ajay Garg wrote:
> > So, is there a way to have the code always in-order; in other words,
> > have the GUI updates absolutely synchronous?
>
> No, not without waiting for the update to complete, and if you do
> this, the code runs very slowly.
>
> (When there is only one CPU, only one process can execute on it at a
> time. The updates are placed in a pipeline to the display, and the
> display process runs them as soon as it is practical to do so. If
> your process does not release the CPU, then your process will likely
> continue executing until it hits something that will cause it to
> release. It is better to be specific and use idle_add to release.)
>
Right.
Now, from what I believe, that there is just one "main" thread, that is
responsible for running the "normal, backend" code, and the same "main"
thread does the GUI updates (of the events present in the display
pipeline), when it has nothing more to do with the "normal, backend" code.
This also means, that doing something like
main_thread.wait()
would be idiotic, as that would stall the GUI updates as well.
So, does there exist a method, that could cause doing the GUI updates in a
different (other than the "main" thread) ?
If yes, that would solve the issue, as the following would then be feasible
::
<main thread> logic statement 1
<main thread> spawn a new thread, and pass the GUI-update event to
it |
<main thread> "joins" on the new
thread |
| anywhere in this interval, the new thread performs the GUI update
|
|
new thread terminates
<main thread> logic statement 2
At first, it seems that the "*<main thread> spawn a new thread, and pass
the GUI-update event to it*" step is trivial.
However, the thing to note that in a default python configuration, all GUI
update events are scheduled in the context of the main thread.
So, only if the GUI update events could be scheduled to be processed in a
custom thread - that would be awesome !!!
Please let me know if any such method exists :)
Thanks and Regards,
Ajay
> --
> James Cameron
> http://quozl.linux.org.au/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20120821/d3644f70/attachment.html>
More information about the Sugar-devel
mailing list