function oldValue = feature( name, optValue )
;%#ok<NOSEM> undocumented
%FEATURE - distcomp-specific features

% Copyright 2009-2021 The MathWorks, Inc.

persistent FEATURE_STRUCT

if isempty( FEATURE_STRUCT )
    % Add new features here.

    % Only use MPIEXEC for local scheduler on non-Mac
    shouldUseMpiexec = ~ismac;
    
    % Only use MSMPI on Windows64
    shouldUseMsmpi = parallel.internal.cluster.canUseMsmpi();
    
    % Vector of normalized values for at what points during the map stage
    % to queue completed mapper output on the asynchronous MPI shuffle-sort.
    mapReduceShuffleSortSteps = 0.5;
    
    FEATURE_STRUCT = struct( ...
        'HadoopReuseWorker', 'Default', ...
        'HadoopUseLogDisplay', false, ...
        'HadoopUseMapperReducerJobName', false, ...
        'LocalUseMpiexec', shouldUseMpiexec, ...
        'LocalUseMsmpi', shouldUseMsmpi, ...
        'MapReduceShuffleSortSteps', mapReduceShuffleSortSteps, ...
        'MapReduceUseSharedFilesystem', 'Default');
    
    % Protect persistent data
    mlock;
end

% Get value and return, set if necessary
if isfield( FEATURE_STRUCT, name )
    oldValue = FEATURE_STRUCT.(name);
else
    error(message('parallel:internal:cluster:UnknownFeature', name));
end

if nargin == 2
    FEATURE_STRUCT.(name) = optValue;
end
end
