Created
August 25, 2022 02:10
-
-
Save cloudwu/29b59a0a35bb009d785fb10eed92deed to your computer and use it in GitHub Desktop.
Resume lua main thread
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <lua.h> | |
#include <lualib.h> | |
#include <lauxlib.h> | |
#include <stdio.h> | |
const char * source = "print 'A' ; coroutine.yield() ; print 'B'"; | |
int | |
main() { | |
lua_State *L = luaL_newstate(); | |
luaL_openlibs(L); | |
luaL_loadstring(L, source); | |
printf("step 1\n"); | |
int r; | |
lua_resume(L, NULL, 0, &r); | |
printf("step 2\n"); | |
lua_resume(L, NULL, 0, &r); | |
lua_close(L); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment