#include "generator.hpp" int i = 0; #define MAX 50 #define YIELD_EVERY 8 Task thread1_main(){ for (int j = 0; j < MAX; ++j){ ++i; if (j % YIELD_EVERY == 0) YIELD; } } Task thread2_main(){ for (int j = 0; j < MAX; ++j){ ++i; if (j % YIELD_EVERY == 0) YIELD; } } int main(){ //this is basically scheduler code now! //create the "cooperative threads / coroutines" auto task_1 = thread1_main(); auto task_2 = thread2_main(); //scheduler: run one task until yield, //then run the next while (i < MAX*2){ task_1(); task_2(); } return i; }