coroutine:

  stackless和stackful

  jmp

  基于switch的trick:

  http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html

  文中提到高德纳另有一套办法.

  

#define crBegin static int state=0; switch(state) { case 0:
#define crReturn(x) do { state=__LINE__; return x; \
                         case __LINE__:; } while (0)
#define crFinish }

int function(void) {
    static int i;
    crBegin;
    for (i = 0; i < 10; i++)
        crReturn(i);
    crFinish;
}

  

相关文章:

  • 2022-01-15
  • 2022-01-29
  • 2021-05-18
  • 2021-09-11
  • 2021-11-27
  • 2022-01-02
  • 2021-08-26
  • 2021-06-29
猜你喜欢
  • 2022-12-23
  • 2021-08-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-20
相关资源
相似解决方案