From 897f357e4bc8875fbdb3f2fce841e59df8f8bc3d Mon Sep 17 00:00:00 2001 From: angie Date: Tue, 11 Jun 2024 11:54:55 -0400 Subject: [PATCH] Remove temporary and permanent threads --- ultramodern/include/ultramodern/threads.hpp | 17 +------- .../include/ultramodern/ultramodern.hpp | 2 - ultramodern/src/threads.cpp | 39 ------------------- 3 files changed, 2 insertions(+), 56 deletions(-) diff --git a/ultramodern/include/ultramodern/threads.hpp b/ultramodern/include/ultramodern/threads.hpp index 5f2a726..00da6ba 100644 --- a/ultramodern/include/ultramodern/threads.hpp +++ b/ultramodern/include/ultramodern/threads.hpp @@ -7,32 +7,19 @@ namespace ultramodern { namespace threads { - enum class GameThreadType { - Normal, - Temporary, - Permanent - }; - struct callbacks_t { - using get_game_thread_type_t = GameThreadType(OSThread* t); using get_game_thread_name_t = std::string(OSThread* t); /** - * TODO: document, I don't understand what this is used for. - */ - get_game_thread_type_t *get_game_thread_type; - - /** - * Allows specifying a custom name for each thread. + * Allows to specifyin a custom name for each thread. Mainly for debugging purposes. * - * If this function is not provided then the thread id will be used as the name. + * If this function is not provided then the thread id will be used as the name of the thread. */ get_game_thread_name_t *get_game_thread_name; }; void set_callbacks(const callbacks_t& callbacks); - GameThreadType get_game_thread_type(OSThread* t); std::string get_game_thread_name(OSThread* t); } } diff --git a/ultramodern/include/ultramodern/ultramodern.hpp b/ultramodern/include/ultramodern/ultramodern.hpp index b39b77e..b144eaa 100644 --- a/ultramodern/include/ultramodern/ultramodern.hpp +++ b/ultramodern/include/ultramodern/ultramodern.hpp @@ -60,8 +60,6 @@ void run_next_thread_and_wait(RDRAM_ARG1); void resume_thread_and_wait(RDRAM_ARG OSThread* t); void schedule_running_thread(RDRAM_ARG PTR(OSThread) t); void cleanup_thread(UltraThreadContext* thread_context); -uint32_t permanent_thread_count(); -uint32_t temporary_thread_count(); struct thread_terminated : std::exception {}; enum class ThreadPriority { diff --git a/ultramodern/src/threads.cpp b/ultramodern/src/threads.cpp index 14e244d..624fe87 100644 --- a/ultramodern/src/threads.cpp +++ b/ultramodern/src/threads.cpp @@ -20,13 +20,6 @@ void ultramodern::threads::set_callbacks(const callbacks_t& callbacks) { threads_callbacks = callbacks; } -ultramodern::threads::GameThreadType ultramodern::threads::get_game_thread_type(OSThread* t) { - if (threads_callbacks.get_game_thread_type == nullptr) { - return GameThreadType::Normal; - } - return threads_callbacks.get_game_thread_type(t); -} - std::string ultramodern::threads::get_game_thread_name(OSThread* t) { if (threads_callbacks.get_game_thread_name == nullptr) { return std::to_string(t->id); @@ -141,9 +134,6 @@ void ultramodern::set_native_thread_name(const std::string& name) { void ultramodern::set_native_thread_priority(ThreadPriority pri) {} #endif -std::atomic_int temporary_threads = 0; -std::atomic_int permanent_threads = 0; - void wait_for_resumed(RDRAM_ARG UltraThreadContext* thread_context) { TO_PTR(OSThread, ultramodern::this_thread())->context->running.wait(); // If this thread's context was replaced by another thread or deleted, destroy it again from its own context. @@ -190,17 +180,6 @@ static void _thread_func(RDRAM_ARG PTR(OSThread) self_, PTR(thread_func_t) entry ultramodern::set_native_thread_name("Game Thread " + ultramodern::threads::get_game_thread_name(self)); ultramodern::set_native_thread_priority(ultramodern::ThreadPriority::High); - switch (ultramodern::threads::get_game_thread_type(self)) { - case ultramodern::threads::GameThreadType::Normal: - break; - case ultramodern::threads::GameThreadType::Temporary: - temporary_threads.fetch_add(1); - break; - case ultramodern::threads::GameThreadType::Permanent: - permanent_threads.fetch_add(1); - break; - } - // Signal the initialized semaphore to indicate that this thread can be started. thread_context->initialized.signal(); @@ -231,24 +210,6 @@ static void _thread_func(RDRAM_ARG PTR(OSThread) self_, PTR(thread_func_t) entry // Dispose of this thread now that it's completed or terminated. ultramodern::cleanup_thread(thread_context); - - switch (ultramodern::threads::get_game_thread_type(self)) { - case ultramodern::threads::GameThreadType::Normal: - break; - case ultramodern::threads::GameThreadType::Temporary: - temporary_threads.fetch_sub(1); - break; - case ultramodern::threads::GameThreadType::Permanent: - break; - } -} - -uint32_t ultramodern::permanent_thread_count() { - return permanent_threads.load(); -} - -uint32_t ultramodern::temporary_thread_count() { - return temporary_threads.load(); } extern "C" void osStartThread(RDRAM_ARG PTR(OSThread) t_) {