function existingValue = defaultMJSCredentialPromptsEnabled(enabled)
    %defaultMJSCredentialPromptsEnabled Enable or disable interactive MJS credential prompts
    %   existingValue = defaultMJSCredentialPromptsEnabled() will return whether
    %   credential prompts are currently enabled or disabled.
    %   existingValue = defaultMJSCredentialPromptsEnabled(enabled) will enable
    %   credential prompts if enabled is true, and disable credential
    %   prompts if false. Returns the previous value before it was set.
    %
    %   NB: To ensure correct behaviour, this method should be called
    %   before any other PCT code is run within a MATLAB session. This will
    %   only affect MJS clusters created after calling this.
    %
    %   See also parallel.internal.cluster.MJSCredentialHandler
    %   See also parallel.internal.cluster.disableMJSCredentialPrompts

    % Copyright 2021 The MathWorks, Inc.
    
    mlock;
    persistent ENABLED;
    if isempty(ENABLED)
        ENABLED = true;
    end
    existingValue = ENABLED;
    if nargin > 0
        ENABLED = enabled;
    end
end

