MITHREAD::JOB Class Reference

Thread job class to manager specific aspects of a job, such as the error state and completion notification. More...

#include <mi32/mithread.h>

List of all members.

Public Types

enum  FLAGS { FLAG_Default = 0x0000, FLAG_Synchronized = 0x0001, FLAG_DeleteWhenCompleted = 0x0002, FLAG_StopIfError = 0x0004 }

Public Member Functions

 JOB (FLAGS flags=FLAG_Default, MISTATUSMANAGER *Manager=0)
virtual ~JOB ()=0
const ERRORSTATEGetErrorState () const
FLAGS GetFlags () const
ID GetID () const
void SetDelegateOnCancelBeforeRun (DELEGATE_VOID_ID delegate)
void SetDelegateOnCompletion (DELEGATE_VOID_ID delegate)

Protected Member Functions

ERRVALUE CheckCancel ()
WORKERGetWorker ()

Private Member Functions

virtual void v_OnCancelBeforeRun ()
virtual ERRVALUE v_RunJob ()=0

Detailed Description

Thread job class to manager specific aspects of a job, such as the error state and completion notification.


Member Enumeration Documentation

Enumerator:
FLAG_Default 

Default, not synchronized, don't delete when complete, don't stop if error.

FLAG_Synchronized 

This job will wait until all other jobs before it are finished.

FLAG_DeleteWhenCompleted 

When completed or cancelled, this job will delete itself, derived class MUST be allocated with new.

FLAG_StopIfError 

Don't run remaining jobs in same queue if get error.


Constructor & Destructor Documentation

MITHREAD::JOB::JOB ( FLAGS  flags = FLAG_Default,
MISTATUSMANAGER Manager = 0 
) [explicit]

Constructor.

Parameters:
Manager Status manager to assign to this job, overrides the default one in WORKER and POOL
virtual MITHREAD::JOB::~JOB (  )  [pure virtual]

Destructor.


Member Function Documentation

ERRVALUE MITHREAD::JOB::CheckCancel (  )  [protected]

Check if the WORKER::CancelJob() has been called.

Returns:
EUserCancel if the job is canceled, '0' if not.
const ERRORSTATE& MITHREAD::JOB::GetErrorState (  )  const [inline]

Get the error state for the thread instance generated by the delegate's return value There exists an ERRORSTATE for each thread created to prevent a thread from clobbering the error state of a different thread.

Therefore to transfer the error state from one thread to another, we use the ERRORSTATE class.

Returns:
Instance of ERRORSTATE class that 'this' created.
FLAGS MITHREAD::JOB::GetFlags (  )  const [inline]

Get the flags set for 'this'.

Returns:
The set of flags for this job
ID MITHREAD::JOB::GetID (  )  const [inline]

Get the ID for 'this'.

Returns:
ID for this job
WORKER* MITHREAD::JOB::GetWorker (  )  [inline, protected]

Get the WORKER instance that this job is running in.

Returns:
Pointer to WORKER if the job is running, NULL if not.
void MITHREAD::JOB::SetDelegateOnCancelBeforeRun ( DELEGATE_VOID_ID  delegate  )  [inline]

Set a delegate that gets called when this job is complete.

void MITHREAD::JOB::SetDelegateOnCompletion ( DELEGATE_VOID_ID  delegate  )  [inline]

Set a delegate that gets called when this job is complete.

virtual void MITHREAD::JOB::v_OnCancelBeforeRun (  )  [private, virtual]

Called if job is cancelled before v_RunJob would be called.

virtual ERRVALUE MITHREAD::JOB::v_RunJob (  )  [private, pure virtual]

Do the actual job.

Returns:
Error code that the job generated or zero if no error. If an error is generated, the error state can be retrieved via GetErrorState().

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

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