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-2019 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 declare this, which will
   % ensure previous usages of MPI are correctly cleaned up.
   if ~isequal(type, 'mpi_mi')
       parallel.internal.mpi.session("start");
   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
