%ClusterPool class for parallel pool objects based on clusters that
% can span across multiple machines
%
%   parallel.ClusterPool is the class for all parallel pool objects based
%   on clusters that can span across multiple machines. Pool objects can be constructed
%   by using the PARPOOL function.
%
%   parallel.ClusterPool methods:
%      addAttachedFiles      - Attach files to pool
%      delete                - Delete the pool of workers
%      listAutoAttachedFiles - lists the files automatically attached to pool
%      parfeval              - Execute function on worker in parallel pool
%      parfevalOnAll         - Execute function on all workers in parallel pool
%      updateAttachedFiles   - Update changed files that are attached to pool
%      ticBytes              - Start counting bytes transferred within parallel pool
%      tocBytes              - Read how many bytes have been transferred since calling ticBytes
%
%   parallel.ClusterPool properties:
%      AutoAddClientPath    - Determines whether user-added-entries on the client's path are added to each worker's path
%      AttachedFiles        - List of files attached to pool
%      Cluster              - Cluster object associated with pool
%      EnvironmentVariables - Names of environment variables that are sent to the workers
%      FevalQueue           - FevalQueue instance of parallel pool
%      IdleTimeout          - Time in minutes after which pool shuts down
%      NumWorkers           - Number of workers comprising this pool
%      SpmdEnabled          - True if the SPMD language construct is enabled
%
%   See also gcp, parcluster, parallel.Pool/addAttachedFiles,
%   parallel.Pool/updateAttachedFiles, parallel.Pool/listAutoAttachedFiles,
%   parallel.Pool/delete, parfor, batch, parpool, parallel.Cluster/parpool

% Copyright 2019 The MathWorks, Inc.

classdef (Sealed) ClusterPool < parallel.internal.pool.AbstractClusterPool
    methods (Access = ?parallel.internal.pool.AbstractClusterPool)
        function aPool = ClusterPool(varargin)
            %ClusterPool - Undocumented constructor. Use GCP or PARPOOL.
            %
            %   See also GCP, PARPOOL.
            
            % We need to lock this MATLAB file to avoid warnings from clear
            % classes when a pool object is stored as gcp.
            mlock;
            aPool = aPool@parallel.internal.pool.AbstractClusterPool(varargin{:});
        end
    end
    
    % Wrappers around AbstractClusterPool to remove internal frames from
    % stack trace. We do not include help comments for these because those
    % are inherited from AbstractClusterPool.
    methods
        function f = parfeval(aPool, varargin)
            try
                f = parfeval@parallel.internal.pool.AbstractClusterPool(aPool, varargin{:});
            catch err
                throw(err);
            end
        end
        
        function f = parfevalOnAll(aPool, varargin)
            try
                f = parfevalOnAll@parallel.internal.pool.AbstractClusterPool(aPool, varargin{:});
            catch err
                throw(err);
            end
        end
        
        function varargout = ticBytes(aPool)
            try
                [varargout{1:nargout}] = ticBytes@parallel.internal.pool.AbstractClusterPool(aPool);
            catch err
                throw(err);
            end
        end
        
        function varargout = tocBytes(aPool, varargin)
            try
                [varargout{1:nargout}] = tocBytes@parallel.internal.pool.AbstractClusterPool(aPool, varargin{:});
            catch err
                throw(err);
            end
        end
        
        function listAutoAttachedFiles(aPool)
            try
                listAutoAttachedFiles@parallel.internal.pool.AbstractClusterPool(aPool);
            catch err
                throw(err);
            end
        end
        
        function addAttachedFiles(aPool, files)
            try
                addAttachedFiles@parallel.internal.pool.AbstractClusterPool(aPool, files);
            catch err
                throw(err);
            end
        end
        
        function updateAttachedFiles(aPool)
            try
                updateAttachedFiles@parallel.internal.pool.AbstractClusterPool(aPool);
            catch err
                throw(err);
            end
        end
    end
end
