parameters: ()
docstring: Drain the simulator in preparation of a checkpoint or memory mode
      switch.
  
      This operation is a no-op if the simulator is already in the
      Drained state.
docstring_summary: Drain the simulator in preparation of a checkpoint or memory mode
      switch.
docstring_tokens: Drain the simulator in preparation of a checkpoint or memory mode switch .
function: def drain():
      """Drain the simulator in preparation of a checkpoint or memory mode
      switch.
  
      This operation is a no-op if the simulator is already in the
      Drained state.
  
      """
  
      # Try to drain all objects. Draining might not be completed unless
      # all objects return that they are drained on the first call. This
      # is because as objects drain they may cause other objects to no
      # longer be drained.
      def _drain():
          # Try to drain the system. The drain is successful if all
          # objects are done without simulation. We need to simulate
          # more if not.
          if _drain_manager.tryDrain():
              return True
  
          # WARNING: if a valid exit event occurs while draining, it
          # will not get returned to the user script
          exit_event = _m5.event.simulate()
          while exit_event.getCause() != 'Finished drain':
              exit_event = simulate()
  
          return False
  
      # Don't try to drain a system that is already drained
      is_drained = _drain_manager.isDrained()
      while not is_drained:
          is_drained = _drain()
  
      assert _drain_manager.isDrained(), "Drain state inconsistent"
function_tokens: def drain ( ) : # Try to drain all objects. Draining might not be completed unless # all objects return that they are drained on the first call. This # is because as objects drain they may cause other objects to no # longer be drained. def _drain ( ) : # Try to drain the system. The drain is successful if all # objects are done without simulation. We need to simulate # more if not. if _drain_manager . tryDrain ( ) : return True # WARNING: if a valid exit event occurs while draining, it # will not get returned to the user script exit_event = _m5 . event . simulate ( ) while exit_event . getCause ( ) != 'Finished drain' : exit_event = simulate ( ) return False # Don't try to drain a system that is already drained is_drained = _drain_manager . isDrained ( ) while not is_drained : is_drained = _drain ( ) assert _drain_manager . isDrained ( ) , "Drain state inconsistent"