slembcke/Tina

Asynchronous IO

ib00 opened this issue · 2 comments

ib00 commented

How suitable are coroutines for asynchronous IO?

In particular, what I have in mind is texture caching / loading.

Hmm. Yes, and I started writing way to many words to answer your question. :) Better yet, I'll point you to a blog post that will hopefully answer all these questions and more. Tina coroutines, and tina_jobs.h implements a lot of these same ideas and is certainly a base you can build on top of if you want. In particular, you'll want to read the section on "Reactors" to answer your asynchronous IO question.

https://graphitemaster.github.io/fibers/

Speaking personally, in the hobby game I've been writing, I just use memory mapped IO instead. Relying on page faults to load data from a file isn't really any better than synchronous IO. Both will cause the thread pool threads to block, but it's easy, and good enough as far my uses.

ib00 commented

Thanks! It makes sense.

It would be nice if there was a very lightweight async-IO library that played nice with job schedulers.