|
CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
|
Thread pool internal data. This is a singleton type with memory management done by access function(s). You should never create instances of it directly. More...
#include <thread_pool.h>
Public Member Functions | |
| bool | QueueUserWorkItem (WaitCallback callback, const System::SharedPtr< System::Object > &state) |
| Adds work item to queue. More... | |
| void | GetAvailableThreads (int &wt, int &cpt) |
| Gets number of available threads. More... | |
| void | GetMaxThreads (int &wt, int &cpt) |
| Gets maximal number of concurrent threads. More... | |
| void | GetMinThreads (int &wt, int &cpt) |
| Gets minimal number of threads being created by pool. More... | |
| bool | SetMaxThreads (int wt, int cpt) |
| Sets number of threads owned by pool. More... | |
| bool | SetMinThreads (int wt, int cpt) |
| Sets minimal number of threads owned by pool. More... | |
| ThreadPoolImpl () | |
| Constructor. More... | |
| ~ThreadPoolImpl () | |
| Destructor. Joins all threads if they were not terminated yet. More... | |
| void | JoinAll () |
| Joins all owned threads. Waits infinitely. More... | |
Static Public Member Functions | |
| static bool & | GetInitialized () |
| Gets initialization state singleton. More... | |
Protected Types | |
| typedef std::pair< WaitCallback, System::SharedPtr< System::Object > > | Job |
| Structure that keeps job callback and parameter to be executed. More... | |
Protected Member Functions | |
| void | Worker () |
| Worker thread function. More... | |
| void | AddWorkers (uint32_t amount) |
| Adds worker threads to the pool. More... | |
| void | DelWorkers (uint32_t amount) |
| Deletes worker threads from the pool. More... | |
Protected Attributes | |
| std::uint32_t | m_max_threads |
| Maximal allowed number of threads to exist simultaneously in the pool. More... | |
| std::uint32_t | m_min_threads |
| Minimal allowed number of threads to be created on request. More... | |
| std::mutex | m_mutex |
| Mutex that blocks thread pool task queue. More... | |
| std::condition_variable | m_cv |
| Condition variable used to keep executor threads waiting. More... | |
| std::queue< Job > | m_queue |
| Jobs queue. More... | |
Thread pool internal data. This is a singleton type with memory management done by access function(s). You should never create instances of it directly.
|
protected |
Structure that keeps job callback and parameter to be executed.
| System::Threading::ThreadPoolImpl::ThreadPoolImpl | ( | ) |
Constructor.
| System::Threading::ThreadPoolImpl::~ThreadPoolImpl | ( | ) |
Destructor. Joins all threads if they were not terminated yet.
|
protected |
Adds worker threads to the pool.
| amount | Number of worker threads to create. |
|
protected |
Deletes worker threads from the pool.
| amount | Number of worker threads to delete. |
| void System::Threading::ThreadPoolImpl::GetAvailableThreads | ( | int & | wt, |
| int & | cpt | ||
| ) |
Gets number of available threads.
| wt | Reference to variable to store number of awailable worker threads. |
| cpt | Reference to variable to store number of awailable IO threads. |
|
static |
Gets initialization state singleton.
| void System::Threading::ThreadPoolImpl::GetMaxThreads | ( | int & | wt, |
| int & | cpt | ||
| ) |
Gets maximal number of concurrent threads.
| wt | Reference to variable to store maximal number of awailable worker threads. |
| cpt | Reference to variable to store maximal number of awailable IO threads. |
| void System::Threading::ThreadPoolImpl::GetMinThreads | ( | int & | wt, |
| int & | cpt | ||
| ) |
Gets minimal number of threads being created by pool.
| wt | Reference to variable to store minimal number of awailable worker threads. |
| cpt | Reference to variable to store minimal number of awailable IO threads. |
| void System::Threading::ThreadPoolImpl::JoinAll | ( | ) |
Joins all owned threads. Waits infinitely.
| bool System::Threading::ThreadPoolImpl::QueueUserWorkItem | ( | WaitCallback | callback, |
| const System::SharedPtr< System::Object > & | state | ||
| ) |
Adds work item to queue.
| callback | Callback function to execute. |
| state | Callback function argument. |
| bool System::Threading::ThreadPoolImpl::SetMaxThreads | ( | int | wt, |
| int | cpt | ||
| ) |
Sets number of threads owned by pool.
| wt | Maximal number of worker threads. |
| cpt | Maximal number of IO threads. |
| bool System::Threading::ThreadPoolImpl::SetMinThreads | ( | int | wt, |
| int | cpt | ||
| ) |
Sets minimal number of threads owned by pool.
| wt | Minimal number of worker threads. |
| cpt | Minimal number of IO threads. |
|
protected |
Worker thread function.
|
protected |
Condition variable used to keep executor threads waiting.
|
protected |
Maximal allowed number of threads to exist simultaneously in the pool.
|
protected |
Minimal allowed number of threads to be created on request.
|
protected |
Mutex that blocks thread pool task queue.
|
protected |
Jobs queue.