← Back to team overview

kicad-developers team mailing list archive

Re: KiCad Coroutines

 

On 01/07/2016 11:39 AM, "Torsten Hüter" wrote:
> Hi Wayne,
> 
> this is of course right, but the idea would be to emulate cooperative multitasking with threads. This is done by synchronizing the threads with condition variables and mutexes. The principle can be found in the articles [1] or [2].
> 
> The idea is good, BUT after further research I'd say that there are two show stoppers:
> 
> (a) it's not recommended to use secondary threads to call GUI functions
> 
> http://docs.wxwidgets.org/trunk/overview_thread.html
> 
> (b) the OpenGL context is only valid for the current thread, it's required to change the context for every thread
> 
> https://www.opengl.org/wiki/OpenGL_and_multithreading
> 
> Ideally rendering and gui handling should happen only in the main thread; but that would be to restrictive for our purposes. 
> 
> This makes threads in my opinion unattractive for coroutines.

Tools in the Tool Framework never directly interact with OpenGL context.
Even if they request some redrawing/refreshing, it happens in OnPaint
(or similar) event handler.

Regards,
Orson

> --
> 
> Yes, state machines or stackless coroutines are possible too, but then the tool-framework code has to be changed a lot. I'll evaluate the other options first. Setjmp/longjmp could work also, but here is stack handling the major issue.
> 
> Thanks,
> Torsten


Attachment: signature.asc
Description: OpenPGP digital signature


Follow ups

References