[Gambas-user] Gambas is not multi-threaded, but...

Benoît Minisini gambas at ...1...
Sat Aug 25 00:37:15 CEST 2012


Hi,

In revision #5076, I added a new gb.task component that allows you to 
run a class in the background.

Internally, the interpreter is "simply" forked. But it's not that 
simple. :-)

How does it work?

Once gb.task is checked in the IDE, you get a new class named "Task".

To run a class in the background:
- That class must inherits Task.
- It must have a public "Main" method that takes no argument and returns 
nothing. That method will be run in the background.

As the method is run by a fork, it has access to every other part of the 
program, except that the main process that run the task will not see any 
change done by the task!

The main process can simply modify some public variables in the task 
class to define the arguments of the task. But allowing the task to talk 
to the main process to give the result of its work is not done yet.

Maybe the task Main() method will have a Variant return value that will 
be transparently serialized, sent to the main process, and deserialize.

Or maybe the standard output of the task will be redirected to a pipe 
read by the main process.

Or maybe the both solutions... I don't know yet.

Another point. I don't think that gb.qt4 or gb.gtk will be usable after 
the fork.

Tell me what you think about all that!

Regards,

-- 
Benoît Minisini




More information about the User mailing list