mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-04 21:50:38 -04:00
add some cheks and error reporting, enable catch SEH in windows
This commit is contained in:
parent
8faba63219
commit
c9d0e86344
8 changed files with 88 additions and 34 deletions
|
@ -1,5 +1,5 @@
|
|||
#include "legacy_coroutines.h"
|
||||
|
||||
#include "error.h"
|
||||
|
||||
#include <thread>
|
||||
#include <atomic>
|
||||
|
@ -116,6 +116,17 @@ static void broadcast_message(EVENT_MSG *msg) {
|
|||
clean_task_table();
|
||||
}
|
||||
|
||||
static void crash_task_exception() {
|
||||
try {
|
||||
throw;
|
||||
} catch (std::exception &e) {
|
||||
display_error("Unhandled exception in task %d: %s",q_current_task(), e.what());
|
||||
} catch (...) {
|
||||
display_error("Unhandled exception in task %d: unknown/crash",q_current_task());
|
||||
}
|
||||
abort();
|
||||
}
|
||||
|
||||
|
||||
int add_task(int stack,TaskerFunctionName fcname,...) {
|
||||
int id = get_new_task_id();
|
||||
|
@ -126,8 +137,12 @@ int add_task(int stack,TaskerFunctionName fcname,...) {
|
|||
new_task->thr = std::thread([&]{
|
||||
new_task->resume_flag.wait(false);
|
||||
new_task->resume_flag = false;
|
||||
fcname(args);
|
||||
clean_up_current_task();
|
||||
try {
|
||||
fcname(args);
|
||||
clean_up_current_task();
|
||||
} catch (...) {
|
||||
crash_task_exception();
|
||||
}
|
||||
});
|
||||
switch_to_task(new_task);
|
||||
return id;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue