Allows the user to controls how many threads can be created for a specific use case or application. Each component or user can create its own manager and therefore minimize its impact on the overall system.
CYIThread manager does not hold CYIThread objects, but is more like a permission mechanism to create a new thread.
(Optional) It is possible to configure the maximum number of threads on the system. As more and more managers are added to the system, each manager will interact with the system configuration and adapt the number of available threads in the manager to accomodate all users in a reasaonable way by reducing the available buffers in each manager. Maximum system thread count could be a hard or a soft limit. There could be a parameter to specify the 'minimum' number of threads a manager can have and the system in that case will not allowed to steal threads from that manager and will have to relax its maximum thread requirement. This behaviour may be beneficial for badly configured system.
Ideal situation is not to change the performance of a component by reducing the number of threads available to it through the thread manager, but after some experimentation, set some hard/fixed limits on each component on the system
| bool CYIThreadManager::GetThread |
( |
uint32_t |
managerId, |
|
|
uint32_t |
timeout = 0 |
|
) |
| |
Request a thread from a manager.
When successful, number of available thread is reduced by one. When no thread is available, it blocks the calling thread until timeout value is reached. If timeout value is 0, it does not block and simply returns error.
When a very long timeout is given and the caller is blocked, the only way to unblock the caller is to have other users return threads to the manager via CYIThreadManager::releaseThread() or delete the manager via CYIThread::deleteManager().
- Parameters
-
| managerId | id of the manager |
| timeout | timeout value in 'ms' |
- Returns
- true when a thread is available, false otherwise