Main Content

findTask

Task objects belonging to job object

Syntax

tasks = findTask(j)
tasks = findTask(j, taskFcn)
[pending running completed] = findTask(j)
tasks = findTask(j,'p1',v1,'p2',v2,...)

Arguments

j

Job object.

tasks

Returned task objects.

pending

Array of tasks in jobobjwhoseStateispending.

running

Array of tasks in jobobjwhoseStateisrunning.

completed

Array of completed tasks in jobobj, i.e., those whoseStateisfinishedorfailed.

p1,p2

Task object properties to match.

v1,v2

Values for corresponding object properties.

Description

tasks = findTask(j)gets a 1-by-N array of task objects belonging to a job objectj. Tasks in the array are ordered by theIDproperty of the tasks, indicating the sequence in which they were created.

tasks = findTask(j, taskFcn)returns an array of task objects that belong to the jobj, usingtaskFcnto select them.taskFcnis a function handle that acceptsj.Tasksas an input argument, and returns a logical array indicating the tasks to return.

[pending running completed] = findTask(j)returns arrays of all task objects stored in the job objectj, sorted bystate. Within each array (pending,running, andcompleted), the tasks are returned in sequence of creation.

tasks = findTask(j,'p1',v1,'p2',v2,...)returns an array of task objects belonging to a job objectj. The returned task objects will be only those matching the specified property-value pairs,p1,v1,p2,v2, etc. The property name must be a character vector, with the value being the appropriate type for that property. For a match, the object property value must be exactly the same as specified, including letter case. For example, if a task’sNameproperty value isMyTask, thenfindTaskwill not find that object while searching for aNameproperty value ofmytask.

Examples

Create a job object.

c = parcluster(); j = createJob(c);

Add a task to the job object.

createTask(j,@rand,1,{10})

Find all task objects now part of jobj.

t = findTask(j)

Tips

If jobjis contained in a remote service,findTaskwill result in a call to the remote service. This could result infindTasktaking a long time to complete, depending on the number of tasks retrieved and the network speed. Also, if the remote service is no longer available, an error will be thrown.

版本历史

Introduced before R2006a