[Gambas-user] Gambas is not multi-threaded, but... (fixed version)

Olivier Cruilles linuxos at ...1896...
Sat Aug 25 00:47:27 CEST 2012


Hi Benoit,

Great news, i'll try it as soon because it's very interesting. Why did you implement that now, just to know ?

Cordialement,

Olivier Cruilles
Mail: linuxos at ...1896...

Le 25 août 2012 à 00:41, Benoît Minisini <gambas at ...1...> a écrit :

> 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 inherit Task.
> - It must have a public "Main" method that takes no argument and returns 
> nothing. That method will be run in the background.
> 
> Instanciate the class, and it will be run automatically as soon as the 
> event loop is run.
> 
> The task object will raise a "Kill" event when it has been terminated.
> 
> You can wait for the end of a task by using its Wait() method.
> 
> You can stop a task by calling its Stop() method.
> 
> You can get the process id of a task with its Handle property.
> 
> 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 of course.
> 
> 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 deserialized.
> 
> 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 inside 
> a fork. I didn't try. But background tasks should normally be used 
> for... background invisible tasks.
> 
> Tell me what you think about all that!
> 
> Regards,
> 
> -- 
> Benoît Minisini
> 
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user




More information about the User mailing list