1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- #pragma once
- #include <windows.h>
- #include "ThreadFunctions.h"
- #include "threadpool_types.h"
- #include <vector>
- class ThreadID : private ThreadFunctions
- {
- public:
- static DWORD CALLBACK thread_func_stub(LPVOID param);
- ThreadID(ThreadFunctions *t_f, HANDLE killswitch, HANDLE global_functions_semaphore, ThreadPoolTypes::HandleList &inherited_handles, volatile LONG *thread_count, HANDLE _max_load_event, int _reserved, int _com_type);
- ~ThreadID();
- void Kill();
-
- bool TryAddHandle(HANDLE new_handle);
- void WaitAddHandle(HANDLE new_handle);
- void AddHandle(HANDLE new_handle);
-
-
- bool TryRemoveHandle(HANDLE handle);
- void WaitRemoveHandle(HANDLE handle);
- void RemoveHandle(HANDLE handle);
-
- using ThreadFunctions::QueueFunction;
- bool IsReserved() const;
- bool IsReleased() const;
- bool CanRunCOM(int flags) const;
- void Reserve();
- void Release();
- private:
- void RemoveHandle_Internal(HANDLE handle);
- DWORD CALLBACK ThreadFunction();
- int reserved;
- ThreadFunctions *global_functions;
- volatile LONG *num_threads_available;
- int com_type;
- bool released;
- ThreadFunctions local_functions;
-
- typedef std::vector<HANDLE> HandleList;
- HandleList wait_handles;
- CRITICAL_SECTION handle_lock;
-
- HANDLE threadHandle;
- HANDLE wakeHandle;
-
- HANDLE max_load_event;
- };
|