Threading to prevent GUI Freeze

Gerald via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jan 4 10:50:40 PST 2016


On Monday, 4 January 2016 at 18:04:34 UTC, TheDGuy wrote:
> On Monday, 4 January 2016 at 17:33:28 UTC, Gerald wrote:
>> On Monday, 4 January 2016 at 16:13:50 UTC, TheDGuy wrote:
>>> [...]
>>
>> Yes, you need it. The extern (C) function is what GDK invokes 
>> on idle. In any GUI application there is a lot of idle time 
>> waiting for events, what the addThreadIdle allows you to do is 
>> take advantage of this and tell GTK that whenever it's sitting 
>> around doing nothing, give this function a call.
>>
>> [...]
>
> Okay, thanks alot for your help. I think i will need some time 
> to understand this but one last question:
>
> Do the errors come from the fact at i didn't use those GTK 
> thread mechanisms or that my function is not "spawnable"?
>
> "std.concurrency.spawn(F, T...)(F fn, T args) 
> if(isSpawnable!(F,T))"
> "Error: template std.concurrency.spawn cannot deduce function 
> from argument types!()(void delegate(Context cr, Widget 
> widget), Scoped Widget), candidates are:"

Keep in mind I know nothing about Cairo and I don't have time to 
try your code, but what happens if you remove the Scoped template 
from the Context parameter?

Also, have you checked if Cairo is thread-safe the way you are 
using it in the spawned function? I'm not sure if Cairo has the 
same restrictions that GTK widgets do.


More information about the Digitalmars-d-learn mailing list