Class to manage multiple threads in a 'pool'. More...
#include <mi32/mithread.h>
Public Member Functions | |
| POOL (UINT32 NumPoolThreads=0, MISTATUSMANAGER *DftManager=0, bool IncludeLogicalCores=false) | |
| ~POOL () | |
| ID | AddQueue (QUEUE &Queue, JOB &Job) |
| ID | AddQueue (QUEUE &Queue, bool AddToFront=false) |
| void | CancelJob (ID JobID) |
| void | CancelQueue (ID QueueID) |
| UINT32 | GetNumActiveThreads () const |
| void | SetDelegateOnCompletion (DELEGATE_VOID_NOPARMS OnCompletion) |
| void | StartQueuedJobs () |
| void | SuspendQueuedJobs () |
| void | WaitForCompletion () |
Class to manage multiple threads in a 'pool'.
The list of jobs to do, called 'QUEUE', is processed to execute the jobs in an available active thread in the pool. After a JOB is completed, it is removed from its queue. When a queue is empty, it is removed from its parent queue.
| MITHREAD::POOL::POOL | ( | UINT32 | NumPoolThreads = 0, |
|
| MISTATUSMANAGER * | DftManager = 0, |
|||
| bool | IncludeLogicalCores = false | |||
| ) |
Ctor.
| NumPoolThreads | The number of pool worker threads to allocate. Default is the number of processor cores. | |
| DftManager | Default status manager to assign any job, unless job overrides it |
| MITHREAD::POOL::~POOL | ( | ) |
Dtor This call will block if jobs are running.
Add a queue to the pool in front of the Job given.
Add a queue to the pool.
| AddToFront | If 'true', places the job queue ahead of all other queues and executes it ASAP. |
| void MITHREAD::POOL::CancelJob | ( | ID | JobID | ) |
Cancel the job referenced by 'JobID'.
Will immediately cancel a job that is waiting to run. If a job is running, will call WORKER::CancelJob()
| JobID | ID of the job |
| void MITHREAD::POOL::CancelQueue | ( | ID | QueueID | ) |
Cancel all jobs and queues referenced by 'QueueID'.
Will immediately cancel jobs that are waiting to run. If jobs are running, will call WORKER::CancelJob() for each job.
| QueueID | ID of the queue |
| UINT32 MITHREAD::POOL::GetNumActiveThreads | ( | ) | const |
Get the number of active threads in the pool.
"Active Threads" are threads that are currently or can be executing MITHREAD::JOB's. If a thread is created because a JOB is blocked waiting for other jobs, that thread is not counted as active.
| void MITHREAD::POOL::SetDelegateOnCompletion | ( | DELEGATE_VOID_NOPARMS | OnCompletion | ) |
Set a delegate that gets called when all the jobs are complete.
| void MITHREAD::POOL::StartQueuedJobs | ( | ) |
Start the jobs added via the AddQueue() methods.
| void MITHREAD::POOL::SuspendQueuedJobs | ( | ) |
Suspend jobs that have not already started.
Jobs will remain in the queue(s)
| void MITHREAD::POOL::WaitForCompletion | ( | ) |
Wait until all of the jobs in the queue are completed.
1.6.1