How to pass class method handle to createTask
조회 수: 5 (최근 30일)
이전 댓글 표시
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
채택된 답변
Edric Ellis
2015년 3월 25일
편집: Edric Ellis
2015년 3월 25일
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)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Cluster Configuration에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!