function [dataOut, functionNotFound] = deserializeFunction(data, freeBuffersAfterDeserialization)
%deserializeFunction deserialize function handles, suppressing warnings
%   Note that it is not possible to determine reliably whether unresolved
%   functions remain, so the caller must simply try to execute the
%   function. However, if the execution fails with MATLAB:UndefinedFunction,
%   they might consider taking a different course of action based on
%   'functionNotFound'.

% Copyright 2013-2017 The MathWorks, Inc.

if nargin < 2
    freeBuffersAfterDeserialization = true;
end

suppressor       = parallel.internal.general.WarningSuppressor(...
    'MATLAB:dispatcher:UnresolvedFunctionHandle');
dataOut          = parallel.internal.pool.deserialize(...
    data, freeBuffersAfterDeserialization);
functionNotFound = suppressor.didSuppressedWarningOccur();
end
