Fiber based UI-Toolkit

Gerald via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jul 10 06:37:45 PDT 2017


On Sunday, 9 July 2017 at 19:43:14 UTC, Christian Köstlin wrote:
> I wonder if there is any fiber based / fiber compatible 
> UI-Toolkit out for dlang. The second question is, if it would 
> make sense at all to have such a thing?

As previously noted, like other UI toolkits GTK maintains a 
single thread for processing UI events with an event loop running 
in that thread. GTK does support passing a function to be called 
when the main loop is idle, it could be possible to leverage this 
to manage fibers with appropriate yielding.

Having said that, I'm in the camp where this doesn't make much 
sense. Using fibers on the main UI thread is likely going to 
result in a blocked UI whenever a fiber takes too long to do its 
work. History has shown that cooperative multi-tasking typically 
doesn't work well for UI applications.

I think you would be much better off starting an additional 
thread and managing fibers in that thread outside the context of 
the main UI thread. You can then use things like std.concurrency 
to receive messages from the external thread to update the UI as 
needed in it's own thread.


More information about the Digitalmars-d-learn mailing list