Files
@ r14248:a9050881acd7
Branch filter:
Location: cpp/openttd-patchpack/source/src/3rdparty/squirrel/samples/coroutines.nut - annotation
r14248:a9050881acd7
602 B
text/plain
(svn r18809) -Codechange/Cleanup: remove unneeded headers from some files, if a header require a header make it include that header
r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 | function coroutine_test(a,b)
{
::print(a+" "+b+"\n");
local ret = ::suspend("suspend 1");
::print("the coroutine says "+ret+"\n");
ret = ::suspend("suspend 2");
::print("the coroutine says "+ret+"\n");
ret = ::suspend("suspend 3");
::print("the coroutine says "+ret+"\n");
return "I'm done"
}
local coro = ::newthread(coroutine_test);
local susparam = coro.call("test","coroutine"); //starts the coroutine
local i = 1;
do
{
::print("suspend passed ["+susparam+"]\n")
susparam = coro.wakeup("ciao "+i);
++i;
}while(coro.getstatus()=="suspended")
::print("return passed ["+susparam+"]\n")
|