Torque3D Documentation / _generateds / ThreadPool::WorkItem

ThreadPool::WorkItem

Engine/source/platform/threads/threadPool.h

An action to execute on a worker thread from the pool.

More...

Public Types

Protected Attributes

The work context of this item.

bool

This flag is set after the execute() method has completed.

Protected Functions

bool

Mark a point in a work item's execution where the item can be safely cancelled.

Execute the actions associated with this work item.

Called when the item has been cancelled.

Public Functions

WorkItem(Context * context)

Construct a new work item.

Return the work context associated with the work item.

Return the item's base priority value.

bool

Has this work item been executed already?

bool

Return true if the work item should be cancelled.

Process the work item.

Detailed Description

An action to execute on a worker thread from the pool.

Work items are concurrently reference-counted and will be automatically released once the last reference disappears.

Public Types

typedef ThreadSafeRefCount< WorkItem > Parent 

Protected Attributes

Context * mContext 

The work context of this item.

bool mExecuted 

This flag is set after the execute() method has completed.

Protected Functions

cancellationPoint()

Mark a point in a work item's execution where the item can be safely cancelled.

This method should be called by subclasses' execute() methods whenever an item can be safely cancelled. When it returns true, the work item should exit from its execute() method.

execute()

Execute the actions associated with this work item.

This is the primary function to implement by subclasses.

Reimplemented by: ImageUtil::CompressJob, AsyncBufferedReadItem, AsyncPacketBufferedInputStream::PacketReadItem, NetAsync::NameLookupWorkItem, AsyncReadItem, AsyncReadItem, AsyncWriteItem

onCancelled()

Called when the item has been cancelled.

Reimplemented by: AsyncBufferedReadItem, AsyncPacketBufferedInputStream::PacketReadItem

Public Functions

WorkItem(Context * context)

Construct a new work item.

Parameters:

context

The work context in which the item should be placed. If NULL, the root context will be used.

~WorkItem()

getContext()

Return the work context associated with the work item.

getPriority()

Return the item's base priority value.

return:

item priority; defaults to 1.0.

hasExecuted()

Has this work item been executed already?

isCancellationRequested()

Return true if the work item should be cancelled.

This method can be overridden by subclasses. It's value will be checked each time cancellationPoint() is called. When it returns true, the item's process() method will exit automatically.

return:

true, if item should be cancelled; default is false.

process()

Process the work item.