restart method

Future<void> restart()

Restarts the isolate manager by stopping and restarting all isolates.

This method:

  1. Pauses all running isolates
  2. Clears the queue state
  3. Creates new isolates with the original configuration

This is useful when you need to:

  • Reset the isolate's internal state
  • Recover from error conditions
  • Apply new configuration changes

Note: Any pending tasks in the queue will be lost during restart. Throws IsolateException if the manager is already stopped.

Implementation

Future<void> restart() async {
  if (_streamController.isClosed) {
    throw const IsolateException(
      'Cannot restart IsolateManager: Instance is already stopped. Create a new instance to perform operations.',
    );
  }

  await pause();
  await start();
}