Products & Services Solutions Academia Support User Community Company

Learn more about Parallel Computing Toolbox   

waitForState - Wait for object to change state

Syntax

waitForState(obj)
waitForState(obj, 'state')
waitForState(obj, 'state', timeout)
OK = waitForState(..., timeout)

Arguments

obj

Job or task object whose change in state to wait for.

'state'

Value of the object's State property to wait for.

timeout

Maximum time to wait, in seconds.

OK

Boolean true if wait succeeds, false if times out.

Description

waitForState(obj) blocks execution in the client session until the job or task identified by the object obj reaches the 'finished' state or fails. For a job object, this occurs when all its tasks are finished processing on remote workers.

waitForState(obj, 'state') blocks execution in the client session until the specified object changes state to the value of 'state'. For a job object, the valid states to wait for are 'queued', 'running', and 'finished'. For a task object, the valid states are 'running' and 'finished'.

If the object is currently or has already been in the specified state, a wait is not performed and execution returns immediately. For example, if you execute waitForState(job, 'queued') for job already in the 'finished' state, the call returns immediately.

waitForState(obj, 'state', timeout) blocks execution until either the object reaches the specified 'state', or timeout seconds elapse, whichever happens first.

OK = waitForState(..., timeout) returns a value of true to OK if the awaited state occurs, or false if the wait times out.

Examples

Submit a job to the queue, and wait for it to finish running before retrieving its results.

submit(job)
waitForState(job, 'finished')
results = getAllOutputArguments(job)

See Also

pause, resume, wait

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS