claudiazanabria / matlabcontrol

Automatically exported from code.google.com/p/matlabcontrol
0 stars 0 forks source link

Unable to simultaneously start two Matlab functions in two separate Matlabs that both never return #8

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What version of matlabcontrol are you using?
4.0.0

What version of MATLAB are you using?
2010b 32bit

What operating system are you using?
10.8.0 Darwin Kernel Version 10.8.0

Are you using matlabcontrol from inside MATLAB or outside MATLAB?
outside

What steps will reproduce the problem?
1.  Create two MatlabProxy connections from outside matlab, and make sure they 
are connected.
2.  Invoke a matlab function on the first MatlabProxy that blocks and does not 
return.
3.  Invoke a matlab function on the second MatlabProxy.

What did you expect to happen? 
Expected second MatlabProxy to also invoke its method in step 3, without 
requiring the first MatlabProxy to finish.

What happened instead?
The code blocks until the first MatlabProxy function is completed, and the 
MatlabProxy does not finish.

Please provide any additional information below.

I am trying to start two processes that run at the same time in Matlab.  Since 
neither process do not return a value and instead are continually running, I am 
unable to start both processes using MatlabControl.

Is this right?  Or, did I miss an option somewhere?

Original issue reported on code.google.com by JacobGMa...@gmail.com on 29 Jul 2012 at 8:23

GoogleCodeExporter commented 8 years ago
I also tried this with 2011b 64bit and had the same issue.

Just to be clear, the issue here is that a thread that does not need a return 
value (i.e. is called with eval() ), should continue and not block in 
JMIWrapper.invokeAndWait.

Or, eval should call some new "invokeAndDontWait" function which does not wait 
for the return value since none is requested.  

I'm still confused why this would be a problem since I have two different 
MatlabProxys.  I'm not sure if I stumbled on a bug or a feature.

Original comment by JacobGMa...@gmail.com on 30 Jul 2012 at 1:12

GoogleCodeExporter commented 8 years ago
What you have described is by design. When you call a method on the proxy the 
Java thread you are calling on blocks until Matlab has completed execution. The 
proxy itself is not blocked, you may call more methods on it from other Java 
threads although this will not cause simultaneous execution as Matlab itself is 
single threaded.

The reason the proxy blocks even when calling a function with a void return 
type is so that it is possible to reliably take action on Matlab's state after 
a given action - this is very problematic in cases where you are taking other 
actions that effect Matlab such as modifying files that Matlab may be asked to 
make use of.

Original comment by nonot...@gmail.com on 18 Feb 2013 at 8:19