diff options
author | Jean-Francois Mauguit <jfmauguit@mac.com> | 2024-09-24 09:03:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-24 09:03:25 -0400 |
commit | bab614c421ed7ae329d26bf028c4a3b1d2450f5a (patch) | |
tree | 12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/nu/threadpool/ThreadFunctions.h | |
parent | 4bde6044fddf053f31795b9eaccdd2a5a527d21f (diff) | |
parent | 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (diff) | |
download | winamp-bab614c421ed7ae329d26bf028c4a3b1d2450f5a.tar.gz |
Merge pull request #5 from WinampDesktop/community
Merge to main
Diffstat (limited to 'Src/nu/threadpool/ThreadFunctions.h')
-rw-r--r-- | Src/nu/threadpool/ThreadFunctions.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Src/nu/threadpool/ThreadFunctions.h b/Src/nu/threadpool/ThreadFunctions.h new file mode 100644 index 00000000..bbc5e6c6 --- /dev/null +++ b/Src/nu/threadpool/ThreadFunctions.h @@ -0,0 +1,31 @@ +#pragma once +#include "api_threadpool.h" +#include <map> +#include <deque> +#include "../AutoLock.h" + +class ThreadFunctions +{ +public: + struct Data + { + api_threadpool::ThreadPoolFunc func; + void *user_data; + intptr_t id; + }; + ThreadFunctions(int create_function_list=1); + ~ThreadFunctions(); + void Add(HANDLE handle, api_threadpool::ThreadPoolFunc func, void *user_data, intptr_t id); + bool Get(HANDLE handle, api_threadpool::ThreadPoolFunc *func, void **user_data, intptr_t *id); + void QueueFunction(api_threadpool::ThreadPoolFunc func, void *user_data, intptr_t id); + bool PopFunction(api_threadpool::ThreadPoolFunc *func, void **user_data, intptr_t *id); + + typedef std::map<HANDLE, const ThreadFunctions::Data*> DataMap; + DataMap data; + Nullsoft::Utility::LockGuard guard; + + typedef std::deque<ThreadFunctions::Data*> FuncList; + FuncList functions_list; + CRITICAL_SECTION functions_guard; + HANDLE functions_semaphore; +}; |