Archive for September, 2012

Cross Platform C++ Threading Today

Friday, September 21st, 2012

C++11 finally brings threading in to the core C++ language. Unfortunately, as my little investigation found, we’re not quite all there yet.

That’s okay though, ’cause as it turns out, most of core function of C++ threading can be emulated using standard C and C++ features. While doing something else, I stumbled upon a library TinyThread++. It’s lightweight (2+1 source files), cross platform, and free+open source in the best ways possible.

TinyThread++ attempts to emulate the usage of standard C++11 threading, in a decent, good enough, compromise way. I like it, so instead of fooling around with pThreads and whatever classic Microsoft APIs do, I’m going to use it. And since it’s so simple (2+1 files), if I need something or need to fix something, it’s right there. Great.

Alternatively, there is an equivalent C variant: