TalanSoft Toolkits  201707
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
Public Member Functions | List of all members
iExecutor Struct Referenceabstract
Inheritance diagram for iExecutor:
iUnknown

Detailed Description

Executes the submitted iRunnable tasks.

This interface provides a way of decoupling task submission from the mechanism of how each task will be run, including the details of thread use, scheduling, etc.

An executor is normally used instead of explicitly creating threads. However the it does not strictly require the execution to be asynchronous.

Public Member Functions

virtual tBool GetIsShutdown () const =0
 Returns true if this executor has been shut down. {Property}. More...
 
virtual tBool GetIsTerminated () const =0
 Returns true if all tasks have completed following shut down. {Property}. More...
 
virtual ni::tBool Execute (iRunnable *aRunnable)=0
 Executes the given runnable at some time in the future. More...
 
virtual Ptr< ni::iFutureSubmit (iRunnable *aRunnable)=0
 Executes the given runnable at some time in the future. More...
 
virtual tBool Shutdown (tU32 anTimeOut)=0
 Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. Blocks until all tasks have completed execution or the timeout occurs. More...
 
virtual tBool ShutdownNow (tU32 anTimeOut)=0
 Attempts to cancel all actively executing tasks, halts the processing of waiting tasks. Blocks until all tasks have completed execution or the timeout occurs. More...
 
virtual tU32 Update (tU32 anTimeSliceInMs)=0
 Update the executor. More...
 
- Public Member Functions inherited from iUnknown
virtual tBool IsOK () const =0
 Check if the object is valid. More...
 
virtual tI32 AddRef ()=0
 Signal that one more reference of the object has been created. More...
 
virtual tI32 Release ()=0
 Release a reference of the object. More...
 
virtual void DeleteThis ()=0
 Bypass any reference counting and delete this object. More...
 
virtual void Invalidate ()=0
 Invalidate the object. More...
 
virtual iUnknownQueryInterface (const tUUID &aIID)=0
 Query an interface. More...
 
virtual void ListInterfaces (iMutableCollection *apLst, tU32 anFlags) const =0
 Fill a UUID list containing the UUIDs of the implemented interfaces. More...
 
virtual tI32 SetNumRefs (tI32 anNumRefs)=0
 Set the reference counter directly. More...
 
virtual tI32 GetNumRefs () const =0
 Get the number of references to this object. More...
 

Member Function Documentation

virtual tBool GetIsShutdown ( ) const
pure virtual

Returns true if this executor has been shut down. {Property}.

virtual tBool GetIsTerminated ( ) const
pure virtual

Returns true if all tasks have completed following shut down. {Property}.

virtual ni::tBool Execute ( iRunnable aRunnable)
pure virtual

Executes the given runnable at some time in the future.

The runnable might execute in a new thread, a thread pool, or in the calling thread, at the discretion of the executor implementation.

Parameters
aRunnablethe runnable to execute.
Returns
false if the executor has been invalidated and cannot execute anymore runnable.
virtual Ptr<ni::iFuture> Submit ( iRunnable aRunnable)
pure virtual

Executes the given runnable at some time in the future.

The runnable might execute in a new thread, a thread pool, or in the calling thread, at the discretion of the executor implementation.

Parameters
aRunnablethe runnable to execute.
Returns
A iFuture that is set to the return value of the runnable when it returns. NULL if the executor has been invalidated and cannot execute anymore runnable.
virtual tBool Shutdown ( tU32  anTimeOut)
pure virtual

Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. Blocks until all tasks have completed execution or the timeout occurs.

Returns
true if this executor terminated and false if the timeout elapsed before termination.
virtual tBool ShutdownNow ( tU32  anTimeOut)
pure virtual

Attempts to cancel all actively executing tasks, halts the processing of waiting tasks. Blocks until all tasks have completed execution or the timeout occurs.

Returns
true if this executor terminated and false if the timeout elapsed before termination.
Remarks
Invalidate calls ShutdownNow(eInvalidHandle).
virtual tU32 Update ( tU32  anTimeSliceInMs)
pure virtual

Update the executor.

Parameters
anTimeSliceInMsthe suggested maximum time allocated to execute the runnables queued in the executor, at least one runnable is executed per update if any are queued.
Returns
The duration (in milliseconds) of the execution of the runnables. Always 0 for immediate and thread pool executors.
Remarks
On multi-threaded platforms this call is superflous for all but the cooperative executors. For the default executors provided in iConcurrent this should be called in the main app's for the main executor (which is always cooperative).