Can't pass COM object handle into spmd body
Show older comments
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!
Accepted Answer
More Answers (1)
Edric Ellis
on 14 Oct 2011
0 votes
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.
1 Comment
matlabUser
on 14 Oct 2011
Categories
Find more on Use COM Objects in MATLAB in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!