Simple "coroutine" implementation in C++11 using threads