Created
July 10, 2022 18:07
-
-
Save jarcode-foss/2eb11c54d3f05409fffd37669245909e to your computer and use it in GitHub Desktop.
This file contains hidden or 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 <stdlib.h> | |
#include <stdio.h> | |
#include <stdbool.h> | |
#include <string.h> | |
#include <assert.h> | |
#include <luabase.h> | |
#include <ct.h> | |
static ct_scheduler frame_scheduler; | |
static ct_task* main_task; | |
static char* lua_source = "assert(pcall(function() io.open(\"doesntexist.txt\", \"r\") end) == false)"; | |
static bool completed = false; | |
static void main_task_f(ct_arg task) { | |
CT_BEGIN(task) { | |
luaL_loadstring(ct_lua_state, lua_source); | |
if (!luaA_calltop(ct_lua_state)) | |
abort(); | |
completed = true; | |
} | |
} | |
int main(int argc, char** argv) { | |
luaA_entry(); | |
ct_init(&frame_scheduler); | |
main_task = schedule(&frame_scheduler, main_task_f, CT_LUA, 0); | |
while (!completed) { | |
ct_enter(&frame_scheduler); | |
async_queue_wait_for_signal(50); | |
} | |
while (true) { | |
/* sleep forever to allow a debugger to attach while the program is gracefully running */ | |
Sleep(1000); | |
printf("application is running!\n"); | |
} | |
printf("returned from scheduler\n"); | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment