How do you implement Coroutines in C++

后端 未结 18 935
刺人心
刺人心 2020-12-02 04:17

I doubt it can be done portably, but are there any solutions out there? I think it could be done by creating an alternate stack and reseting SP,BP, and IP on function entry

18条回答
  •  温柔的废话
    2020-12-02 04:50

    Check out my implementation, it illustrates the asm hacking point and is simple:

    https://github.com/user1095108/generic/blob/master/coroutine.hpp

提交回复
热议问题