From aa898f6ac9f5c8ec7129e51e6af6da2f1cf3844e Mon Sep 17 00:00:00 2001 From: Wins1ey <34382191+Wins1ey@users.noreply.github.com> Date: Fri, 15 Mar 2024 02:57:20 +0000 Subject: [PATCH] Moved last_auto_splitter to last-gtk.c and removed 2nd pthread --- src/auto-splitter.c | 12 ------------ src/auto-splitter.h | 4 ++-- src/last-gtk.c | 35 +++++++++++++++-------------------- 3 files changed, 17 insertions(+), 34 deletions(-) diff --git a/src/auto-splitter.c b/src/auto-splitter.c index 6dda903..c879b25 100644 --- a/src/auto-splitter.c +++ b/src/auto-splitter.c @@ -261,15 +261,3 @@ void run_auto_splitter() lua_close(L); } - -void *last_auto_splitter() -{ - while (true) - { - if (atomic_load(&auto_splitter_enabled) && auto_splitter_file[0] != '\0') - { - run_auto_splitter(); - } - usleep(1000000); // Wait for 1 second before checking again - } -} \ No newline at end of file diff --git a/src/auto-splitter.h b/src/auto-splitter.h index 9bde8ba..0462a07 100644 --- a/src/auto-splitter.h +++ b/src/auto-splitter.h @@ -11,6 +11,6 @@ extern atomic_bool call_reset; extern char auto_splitter_file[256]; void check_directories(); -void *last_auto_splitter(); +void run_auto_splitter(); -#endif /* __AUTO_SPLITTER_H__ */ \ No newline at end of file +#endif /* __AUTO_SPLITTER_H__ */ diff --git a/src/last-gtk.c b/src/last-gtk.c index 63eb0ec..d301dd2 100644 --- a/src/last-gtk.c +++ b/src/last-gtk.c @@ -1162,31 +1162,26 @@ static void last_app_class_init(LASTAppClass *class) G_APPLICATION_CLASS(class)->open = last_app_open; } -struct ThreadArgs { - int argc; - char** argv; -}; - -void* run_application(void* args) { - struct ThreadArgs* threadArgs = (struct ThreadArgs*)args; - int argc = threadArgs->argc; - char** argv = threadArgs->argv; - g_application_run(G_APPLICATION(last_app_new()), argc, argv); +static void *last_auto_splitter() +{ + while (1) { + if (atomic_load(&auto_splitter_enabled) && auto_splitter_file[0] != '\0') + { + run_auto_splitter(); + } + usleep(50000); + } return NULL; } -int main(int argc, char *argv[]) { +int main(int argc, char *argv[]) +{ check_directories(); - pthread_t t1, t2; - struct ThreadArgs threadArgs; - threadArgs.argc = argc; - threadArgs.argv = argv; - pthread_create(&t1, NULL, &run_application, (void*)&threadArgs); - pthread_create(&t2, NULL, &last_auto_splitter, NULL); - + pthread_t t1; + pthread_create(&t1, NULL, &last_auto_splitter, NULL); + g_application_run(G_APPLICATION(last_app_new()), argc, argv); pthread_join(t1, NULL); - pthread_join(t2, NULL); return 0; -} \ No newline at end of file +}