Updating built in Io code to use += instead of x = x + y
[io/quag.git] / libs / coroutine / samples / twoCoroTest.c
blob4d4a4064717696944dc5f0fb202cd5ee549637c5
1 #include "Coro.h"
2 #include <stdio.h>
4 Coro *firstCoro, *secondCoro;
6 void secondTask(void *context)
8 int num = 0;
10 printf("secondTask created with value %d\n", *(int *)context);
12 while (1)
14 printf("secondTask: %d %d\n", (int)Coro_bytesLeftOnStack(secondCoro), num++);
15 Coro_switchTo_(secondCoro, firstCoro);
19 void firstTask(void *context)
21 int value = 2;
22 int num = 0;
24 printf("firstTask created with value %d\n", *(int *)context);
25 secondCoro = Coro_new();
26 Coro_startCoro_(firstCoro, secondCoro, (void *)&value, secondTask);
28 while (1)
30 printf("firstTask: %d %d\n", (int)Coro_bytesLeftOnStack(firstCoro), num++);
31 Coro_switchTo_(firstCoro, secondCoro);
35 int main()
37 Coro *mainCoro = Coro_new();
38 int value = 1;
40 Coro_initializeMainCoro(mainCoro);
42 firstCoro = Coro_new();
43 Coro_startCoro_(mainCoro, firstCoro, (void *)&value, firstTask);