start method
Implementation
Future<void> start(
int isolates,
Future<Server> Function(SendPort?) spawn,
) async {
if (isRunning) {
// TODO(isolate): update error message.
throw StateError('Server is already running.');
}
try {
for (var isolate = 0; isolate < isolates; isolate += 1) {
var supervisor =
await IsolateSupervisor.spawn(this, spawn, isolate + 1);
supervisors.add(supervisor);
await supervisor.resume();
}
for (var isolate = 0; isolate < isolates; isolate += 1) {
supervisors[isolate].sendPendingMessages();
}
isRunning = true;
} catch (error) {
await close();
}
}