Thoughts and Opinions on Coding and Tech
-
Why cooperative multitasking is a bad idea
Maybe you are already familiar with coroutines and cooperative multitasking as it exists in python. The upcoming C++20 extensions to C++ will include coroutines with which something equivalent can be implemented quite easily. In my recreational C++ playtime I’ve recently played with coroutines and generators and discovered that cooperative multitasking is unlikely to outperform threaded multitasking.
-
Playing with generators in C++
I wanted to play with generators and coroutines in C++. Coroutines are a feature I really like in python. In a nutshell a coroutine is a function that can suspend itself and return a value on each suspend. This is called
yielding
. The next iteration of C++ will include coroutines and add the keywordco_yield
to perform yielding. In this post I’ll show my implementation of a coroutine-like generator. -
Simplyfile
To simplify and RAII-fy linux file handles I’ve created a super small C++ library “simplyfile” some time ago. The library is actually not special and you could imagine how the code looks like (close on destruction and some moves). However, there are two reasons I prefer dealing with files encapsulated in simplyfile’s handles: