Add a method to see whether a WorkItem has executed yet.

This commit is contained in:
Daniel Buckmaster 2015-07-05 12:40:50 +10:00
parent 5caf62b19f
commit 7b2cb8d04f
2 changed files with 12 additions and 1 deletions

View file

@ -120,6 +120,7 @@ void ThreadPool::Context::updateAccumulatedPriorityBiases()
void ThreadPool::WorkItem::process()
{
execute();
mExecuted = true;
}
//--------------------------------------------------------------------------

View file

@ -194,6 +194,9 @@ class ThreadPool
/// This is the primary function to implement by subclasses.
virtual void execute() = 0;
/// This flag is set after the execute() method has completed.
bool mExecuted;
public:
/// Construct a new work item.
@ -201,7 +204,8 @@ class ThreadPool
/// @param context The work context in which the item should be placed.
/// If NULL, the root context will be used.
WorkItem( Context* context = 0 )
: mContext( context ? context : Context::ROOT_CONTEXT() )
: mContext( context ? context : Context::ROOT_CONTEXT() ),
mExecuted( false )
{
}
@ -229,6 +233,12 @@ class ThreadPool
/// Return the item's base priority value.
/// @return item priority; defaults to 1.0.
virtual F32 getPriority();
/// Has this work item been executed already?
bool hasExecuted() const
{
return mExecuted;
}
};
typedef ThreadSafeRef< WorkItem > WorkItemPtr;