function map = hGetCompositeKeysToClearMap(varargin)
%HGETCOMPOSITEKEYSTOCLEARMAP Helper for threads that returns
% an instance of the parallel.internal.pool.ProcessKeyMap.

% Copyright 2021 The MathWorks, Inc.

    persistent COMPOSITE_KEYS_TO_CLEAR_MAP

    mlock;

    if nargin && strcmp(varargin{1},'clear')
        COMPOSITE_KEYS_TO_CLEAR_MAP = [];
    elseif isempty(COMPOSITE_KEYS_TO_CLEAR_MAP)
        COMPOSITE_KEYS_TO_CLEAR_MAP = parallel.internal.pool.ProcessKeyMap();
    end

    map = COMPOSITE_KEYS_TO_CLEAR_MAP;

end
