MITHREAD::POOL Class Reference

Class to manage multiple threads in a 'pool'. More...

#include <mi32/mithread.h>

List of all members.

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 ()

Detailed Description

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.


Constructor & Destructor Documentation

MITHREAD::POOL::POOL ( UINT32  NumPoolThreads = 0,
MISTATUSMANAGER DftManager = 0,
bool  IncludeLogicalCores = false 
)

Ctor.

Parameters:
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.


Member Function Documentation

ID MITHREAD::POOL::AddQueue ( QUEUE Queue,
JOB Job 
)

Add a queue to the pool in front of the Job given.

Returns:
The ID of the queue added
Parameters:
Job If 'Job' adds a QUEUE, this must be set to 'Job' so that the 'Queue' can be properly placed in front of 'Job' and 'Job' blocked until its queue is done. NULL refers to the thread that owns 'this' POOL.
ID MITHREAD::POOL::AddQueue ( QUEUE Queue,
bool  AddToFront = false 
)

Add a queue to the pool.

Returns:
The ID of the queue added
Parameters:
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()

Parameters:
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.

Parameters:
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.

Returns:
Number of active threads in the pool.
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.


The documentation for this class was generated from the following file:

Generated on Sun Oct 7 21:36:39 2012 for TNTsdk 2012 by  doxygen 1.6.1