Can't pass COM object handle into spmd body
显示 更早的评论
I am using an application object opened using ActiveX server,
oApp = actxserver('my.application');
in the definition of an anonymous function,
fHandle = @(x) myFunction(x,oApp);
(I am processing the data 'x' with an external application 'my.application'.)
This function handle works fine when I call it form the MATLAB client, like this:
fHandle(5)
ans =
100
However, when I call it from within spmd body,
spmd
if labindex == 1
y = fHandle(x);
end
.....
end
I am getting an error message like "Trying to reference an un-structured object", and you can see this object is oApp. So, the lab from the spmd pool does not oApp as a valid application object. I tried to open this object inside the spmd body, but I cannot define an anonymous function there (documentation says the same).
Can anybody please give me a hint how to solve this problem? -Thanks a lot!
采纳的回答
更多回答(1 个)
Edric Ellis
2011-10-14
0 个投票
As you've discovered, there are some limitations with passing handle-type objects into the body of SPMD blocks. This is because the workers executing the SPMD block are separate processes, potentially on separate machines. Therefore the data is effectively saved and reloaded (but without going via the disk).
Perhaps you could use my 'WorkerObjectWrapper' which is designed to help managing the lifetime of objects to be used within SPMD and PARFOR.
类别
在 帮助中心 和 File Exchange 中查找有关 Use COM Objects in MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!