[Gambas-user] Tasks
Benoît Minisini
gambas at ...1...
Wed Jan 29 18:07:13 CET 2014
Le 28/01/2014 13:26, Fabien Bodard a écrit :
> Hi Benoit,
>
> I'm currently working on a new viewer for reports. As drawing report in
> real time is quite long, I use images stored in a collection to have a
> buffer.
>
> I have trying to use task to process the painting of the report on an image
> that I return through the value, like you are doing in fractal example.
>
> So in the _new I'm giving theses args :
>
> (Hreport as report, ipage as integer, fscale, iwidth, iheight)
>
> Then the main sub call $hreport.paint($ipage) to draw the page
>
> But a this point report class return an I/O error... Why ?
I don't know, but you can't use QT4 or GTK+ reliably inside a task. :-(
>
> Can't I use a class instantiate in the main processus in the slave one ?
>
It depends. The task is a fork of the main process, so it can use
everything theoritically, except when there is a file descriptor
somewhere in the story: problems begin.
As for QT4 or GTK+, I think you should be able to use them in a task as
soon as there is no communication with the X server. You must test case
by case and pray.
Think about TTF fonts: it can be opened in the main process, then use in
the child process, while being closed in the main process... Can it be a
problem? I don't know.
> In other hand, is there a way to re-use a task class after the return
> without instanciate it a new time, and if it's possible, how to run it with
> new args.
No. If the task ends, the child process has disappeared, so you must
create a new one. One task instance equals one process instance.
--
Benoît Minisini
More information about the User
mailing list