rosalina: make the task runner thread actually exit
This commit is contained in:
parent
1d8b793cf7
commit
9d62995799
@ -4,6 +4,11 @@
|
||||
|
||||
TaskRunner g_taskRunner;
|
||||
|
||||
static void taskRunnerNoOpFunction(void *args)
|
||||
{
|
||||
(void)args;
|
||||
}
|
||||
|
||||
void TaskRunner_Init(void)
|
||||
{
|
||||
memset(&g_taskRunner, 0, sizeof(TaskRunner));
|
||||
@ -20,12 +25,23 @@ void TaskRunner_RunTask(void (*task)(void *argdata), void *argdata, size_t argsi
|
||||
LightEvent_Signal(&g_taskRunner.parametersSetEvent);
|
||||
}
|
||||
|
||||
void TaskRunner_Terminate(void)
|
||||
{
|
||||
g_taskRunner.shouldTerminate = true;
|
||||
TaskRunner_RunTask(taskRunnerNoOpFunction, NULL, 0);
|
||||
}
|
||||
|
||||
void TaskRunner_HandleTasks(void *p)
|
||||
{
|
||||
(void)p;
|
||||
for (;;) {
|
||||
while (!g_taskRunner.shouldTerminate) {
|
||||
LightEvent_Signal(&g_taskRunner.readyEvent);
|
||||
LightEvent_Wait(&g_taskRunner.parametersSetEvent);
|
||||
g_taskRunner.task(g_taskRunner.argStorage);
|
||||
}
|
||||
}
|
||||
|
||||
void TaskRunner_WaitReady(void)
|
||||
{
|
||||
LightEvent_Wait(&g_taskRunner.readyEvent);
|
||||
}
|
||||
|
@ -8,11 +8,15 @@ typedef struct TaskRunner {
|
||||
LightEvent parametersSetEvent;
|
||||
void (*task)(void *argdata);
|
||||
u8 argStorage[0x40];
|
||||
bool shouldTerminate;
|
||||
} TaskRunner;
|
||||
|
||||
extern TaskRunner g_taskRunner;
|
||||
|
||||
void TaskRunner_Init(void);
|
||||
void TaskRunner_RunTask(void (*task)(void *argdata), void *argdata, size_t argsize);
|
||||
void TaskRunner_Terminate(void);
|
||||
|
||||
/// Thread function
|
||||
void TaskRunner_HandleTasks(void *p);
|
||||
void TaskRunner_WaitReady(void);
|
||||
|
@ -9,6 +9,7 @@ typedef struct TaskRunner {
|
||||
LightEvent parametersSetEvent;
|
||||
void (*task)(void *argdata);
|
||||
u8 argStorage[0x40];
|
||||
bool shouldTerminate;
|
||||
} TaskRunner;
|
||||
|
||||
extern TaskRunner g_taskRunner;
|
||||
@ -17,6 +18,8 @@ MyThread *taskRunnerCreateThread(void);
|
||||
|
||||
void TaskRunner_Init(void);
|
||||
void TaskRunner_RunTask(void (*task)(void *argdata), void *argdata, size_t argsize);
|
||||
void TaskRunner_Terminate(void);
|
||||
|
||||
/// Thread function
|
||||
void TaskRunner_HandleTasks(void);
|
||||
void TaskRunner_WaitReady(void);
|
@ -163,10 +163,9 @@ static void handleTermNotification(u32 notificationId)
|
||||
|
||||
static void handleNextApplicationDebuggedByForce(u32 notificationId)
|
||||
{
|
||||
int dummy;
|
||||
(void)notificationId;
|
||||
// Following call needs to be async because pm -> Loader depends on rosalina hb:ldr, handled in this very thread.
|
||||
TaskRunner_RunTask(debuggerFetchAndSetNextApplicationDebugHandleTask, &dummy, 0);
|
||||
TaskRunner_RunTask(debuggerFetchAndSetNextApplicationDebugHandleTask, NULL, 0);
|
||||
}
|
||||
|
||||
static const ServiceManagerServiceEntry services[] = {
|
||||
@ -204,6 +203,8 @@ int main(void)
|
||||
if (R_FAILED(ServiceManager_Run(services, notifications, NULL)))
|
||||
svcBreak(USERBREAK_PANIC);
|
||||
|
||||
TaskRunner_Terminate();
|
||||
|
||||
MyThread_Join(menuThread, -1LL);
|
||||
MyThread_Join(taskRunnerThread, -1LL);
|
||||
MyThread_Join(errDispThread, -1LL);
|
||||
|
@ -7,7 +7,10 @@ TaskRunner g_taskRunner;
|
||||
static MyThread taskRunnerThread;
|
||||
static u8 ALIGN(8) taskRunnerThreadStack[0x1000];
|
||||
|
||||
extern bool terminationRequest;
|
||||
static void taskRunnerNoOpFunction(void *args)
|
||||
{
|
||||
(void)args;
|
||||
}
|
||||
|
||||
MyThread *taskRunnerCreateThread(void)
|
||||
{
|
||||
@ -32,9 +35,15 @@ void TaskRunner_RunTask(void (*task)(void *argdata), void *argdata, size_t argsi
|
||||
LightEvent_Signal(&g_taskRunner.parametersSetEvent);
|
||||
}
|
||||
|
||||
void TaskRunner_Terminate(void)
|
||||
{
|
||||
g_taskRunner.shouldTerminate = true;
|
||||
TaskRunner_RunTask(taskRunnerNoOpFunction, NULL, 0);
|
||||
}
|
||||
|
||||
void TaskRunner_HandleTasks(void)
|
||||
{
|
||||
while (!terminationRequest) {
|
||||
while (!g_taskRunner.shouldTerminate) {
|
||||
LightEvent_Signal(&g_taskRunner.readyEvent);
|
||||
LightEvent_Wait(&g_taskRunner.parametersSetEvent);
|
||||
g_taskRunner.task(g_taskRunner.argStorage);
|
||||
|
Reference in New Issue
Block a user