function dctStoreFunctionArray(action, postFcns)
; %#ok Undocumented

% Copyright 2006-2012 The MathWorks, Inc.

% This function should be called to finish any interactive session
% that has been started by a parallel job that has pIsInteractiveJob
% true. 

% Lock this file as it holds information about wrapping up a parallel
% interactive job that needs to persist across a call to clear functions.
mlock;
persistent thePostFcns;
% Ensure that we initialize the post functions correctly
if isempty(thePostFcns)
    thePostFcns = {};
end


switch lower(action)
    case 'set'
        dctSchedulerMessage(5, 'dctStoreFunctionArray(''set'') called with %d functions.', ...
                            numel(postFcns));
        thePostFcns = postFcns;
    case 'run'
        dctSchedulerMessage(5, 'dctStoreFunctionArray(''run'') called with %d functions.', ...
                            numel(thePostFcns));
        dctEvaluateFunctionArray(thePostFcns);
        % Clear out the functions correctly
        thePostFcns = {};
    otherwise
        error(message('parallel:internal:cluster:StoreFunctionArrayInvalidAction'));
end
