function pctPreRemoteEvaluation( type )
; %#ok Undocumented

% This function is called prior to execution of either parfor or spmd to
% ensure the workers are in the correct state.

% Copyright 2008-2017 The MathWorks, Inc.

   % If type is not equal to 'mpi_mi', the calling PCT language feature
   % intends to take ownership of MPI. We need to make sure that
   % mapreduce is not using MPI asynchronously.
   if ~isequal(type, 'mpi_mi')
       parallel.internal.mapreduce.ensureCleanState();
   end
   
   % Ensure that we use the correct MPI functionality for this parfor/spmd
   dctRegisterMpiFunctions( type );
   
   % Ensure that we have picked up any changes to the path before
   % deserialization - this ensures that files created or changed after the
   % pool was opened are correctly interpreted
   if com.mathworks.toolbox.distcomp.pmode.RehashNotificationCommand.resetRehashRequestCount()
       rehash;
   end
end
