Skip to content

Commit

Permalink
version 0.2.7 - fixes Matlab 2014a problems.
Browse files Browse the repository at this point in the history
  • Loading branch information
kotowicz committed Jul 9, 2014
1 parent d776bda commit 87df989
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## A) About

This is version 0.2.6 of `ParforProgress2`, a simple parfor progress monitor for matlab. See also http://www.mathworks.com/matlabcentral/fileexchange/35609-matlab-parforprogress2.
This is version 0.2.7 of `ParforProgress2`, a simple parfor progress monitor for matlab. See also http://www.mathworks.com/matlabcentral/fileexchange/35609-matlab-parforprogress2.

This progress monitor comes with a nice wrapper [`ParforProgressStarter2.m`](ParforProgressStarter2.m) which will take care of adding the classes to the java class path, depending on whether matlabpool / parpool is enabled or not.

Expand Down
34 changes: 25 additions & 9 deletions pool_size.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,31 @@

%% get pool size - this should work for ALL matlab versions
try
session = com.mathworks.toolbox.distcomp.pmode.SessionFactory.getCurrentSession;

x = 0;
if ~isempty( session ) && session.isSessionRunning() && session.isPoolManagerSession()

try % this will only work with matlab <= 2013b
session = com.mathworks.toolbox.distcomp.pmode.SessionFactory.getCurrentSession;

try % works with matlab >= 2009b AND 2013a
x = session.getPoolSize();
catch % works with matlab < 2013a
client = distcomp.getInteractiveObject();
if strcmp( client.CurrentInteractiveType, 'matlabpool' )
x = session.getLabs().getNumLabs();
if ~isempty( session ) && session.isSessionRunning() && session.isPoolManagerSession()

try % works with matlab >= 2009b && <= 2013b
x = session.getPoolSize();
catch % works with any matlab version <= 2012b
client = distcomp.getInteractiveObject();
if strcmp( client.CurrentInteractiveType, 'matlabpool' )
x = session.getLabs().getNumLabs();
end
end
end

catch % check for matlab == 2014a
poolobj = gcp('nocreate');
if isempty(poolobj)
x = 0;
else
x = poolobj.NumWorkers;
end
end

catch me %#ok<NASGU>
Expand All @@ -29,10 +41,14 @@


%% is matlabpool / parpool active?
active = return_active(x);

end

function active = return_active(x)
active = 0;
if x > 0
active = 1;
end

end
%% EOF

0 comments on commit 87df989

Please sign in to comment.