look for boost coroutine and boost.context