Fibers in Libdex
blogs.gnome.org·10h

I’ve talked a lot about fibers before. But what are they and how do they work?

From the progammer perspective they can feel a lot like a thread. They have a stack just like a real thread. They maintain a program counter just like a real thread. They can spill registers to the stack like a real thread.

Most importantly is that you can call into GTK from your fiber if running on the main thread. Your fiber will have been dispatched from the main loop on the same OS thread so this is a great use of libdex.

There are downsides too though. You have to allocate stack and guard pages for them like a read thread. They have some cost in transitioning between stacks even if fairly low these days. You also need to be mindful to own the lifecycle of pointers on your stack if you intend to…

Similar Posts

Loading similar posts...