www.gusucode.com > mbc 工具箱 matlab 源码程序 > mbc/@mbcfoundation/@DCTManager/pSetScheduler.m

    function [ok, errmsg] = pSetScheduler(manager, varargin)
%PSETSCHEDULER Method for getting the DCT scheduler
%
%  [OK, ERRMSG] = PSETSCHEDULER(MANAGER) attempts to find the scheduler
%  defined by the current configuration.
%
%  [OK, ERRMSG] = PSETSCHEDULER(MANAGER, PROP, VAL, ...) uses the supplied
%  property-value pair list to try and find a unique scheduler, if the
%  configuration does not find a unique one.

%  Copyright 2006-2012 The MathWorks, Inc. 

errmsg = '';

ok = ~isempty(manager.Configuration);
if ~ok
    errmsg = 'Configuration has not been set.';
    return
end

ok = manager.checkoutDCTLicense;
if ~ok
    errmsg = 'Unable to check out license for Parallel Computing Toolbox.';
    return
end

try
    resource = parcluster(manager.Configuration);
catch ME
    errmsg = ME.message;
    ok = false;
    return
end
    
if numel(resource)>1 && nargin>1
    % If extra param-value pairs are provided, try to use these to narrow
    % down the choice
    resource = find(resource, varargin{:});
end

if isempty(resource)
    errmsg = sprintf('No scheduler could be found for the configuration "%s".', ...
        manager.Configuration);
    ok = false;
    return
elseif numel(resource) > 1
    errmsg = sprintf(['More than one scheduler was found for the configuration "%s".', ...
        '  Please use the Configurations Manager to create a unique configuration.'], ... 
        manager.Configuration);
    ok = false;
    return
end

% We have passed all the tests and have a single scheduler resource
manager.Scheduler = resource;