bug fix in xrange() that would cause it to yield bogus values
[vox.git] / examples / coroutines.vx
blob24d065a462bcd5782ef51beb80c6e54ad3869f5f
1 function coroutine_test(a, b)\r
2 {\r
3     println(a, " ", b);\r
4     local ret = system.suspend("suspend 1");\r
5     println("the coroutine says ", ret);\r
6     ret = system.suspend("suspend 2");\r
7     println("the coroutine says: ", ret);\r
8     ret = system.suspend("suspend 3");\r
9     println("the coroutine says ", ret);\r
10     return "I'm done"\r
11 }\r
13 local coro = system.newthread(coroutine_test);\r
14 local susparam = coro.call("test","coroutine"); //starts the coroutine\r
16 local i = 1;\r
17 do\r
18 {\r
19     println("suspend passed [", susparam, "]")\r
20     susparam = coro.wakeup("ciao "+i);\r
21     ++i;\r
22 }while(coro.getstatus()=="suspended")\r
24 println("return passed [", susparam, "]")