Products & Services Solutions Academia Support User Community Company

Learn more about Parallel Computing Toolbox   

getCurrentWorker - Worker object currently running this session

Syntax

worker = getCurrentWorker

Arguments

worker

The worker object that is currently evaluating the task that contains this function.

Description

worker = getCurrentWorker returns the worker object representing the session that is currently evaluating the task that calls this function.

Remarks

If the function is executed in a MATLAB session that is not a worker or if you are using a third-party scheduler instead of a job manager, you get an empty result.

Examples

Create a job with one task, and have the task return the name of the worker that evaluates it.

jm = findResource('scheduler','type','jobmanager', ...
          'name','MyJobManager','LookupURL','JobMgrHost');
j = createJob(jm);
t = createTask(j, @() get(getCurrentWorker,'Name'), 1, {});
submit(j)
waitForState(j)
get(t,'OutputArgument')
ans = 
    'c5_worker_43'

The function of the task t is an anonymous function that first executes getCurrentWorker to get an object representing the worker that is evaluating the task. Then the task function uses get to examine the Name property value of that object. The result is placed in the OutputArgument property of the task.

See Also

getCurrentJob, getCurrentJobmanager, getCurrentTask, getFileDependencyDir

  


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