How to pass class method handle to createTask
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
sun peng
am 24 Mär. 2015
Kommentiert: sun peng
am 27 Mär. 2015
Hi,
The Matlab parallel computing toolbox function createTask needs a function handle as the input which it executes on a worker machine. But in all the documents and examples I can find the handle is a plain function handle. I'm wondering if it is possible to pass in a class method handle? That is, I first create a class on the worker machine, and later I want its method be called as a task. If it is impossible, is there any working around (e.g., certain Design Pattern, a trick like message queue, etc.)?
Thanks :)
Peng
0 Kommentare
Akzeptierte Antwort
Edric Ellis
am 25 Mär. 2015
Bearbeitet: Edric Ellis
am 25 Mär. 2015
Remember that MATLAB class methods can always be invoked in the "functional" form, like so:
e = MException('some:identifier', 'This is the message');
report = getReport(e); % same as e.getReport();
Therefore, you can simply specify the method you wish to invoke as the function, and pass the object as the first argument, like so:
j = createJob(parcluster());
t = createTask(j, @getReport, 1, ...
{MException('some:identifier', 'This is the message.')});
submit(j); wait(j);
fetchOutputs(j)
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Cluster Configuration finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!