startIsolateJob method
Future<void>
startIsolateJob(
- IsolateInitParams isolateInitParams,
- EntryPoint<
IsolateInitParams> entryPoint
inherited
Isolates currently not suitable for our purpose. Most UI canvas calls are not accessible from isolates so we cannot produce the bitmap.
Implementation
@protected
Future<void> startIsolateJob(
T isolateInitParams, EntryPoint<T> entryPoint) async {
try {
return await _queue.add(() async {
// logNow("start sendport=$_sendPort");
if (_sendPort != null) return;
int _time = DateTime.now().millisecondsSinceEpoch;
ReceivePort receivePort = ReceivePort();
isolateInitParams.sendPort = receivePort.sendPort;
_isolate = await Isolate.spawn<T>(entryPoint, isolateInitParams);
// let the listener run in background
Completer<SendPort> completer = Completer<SendPort>();
// logNow("start sendport=$_sendPort vor listen");
unawaited(_listenToIsolate(receivePort, completer));
// logNow("start sendport=$_sendPort nach listen");
_sendPort = await completer.future;
// logNow("start sendport=$_sendPort nach setSendPort");
_log.info(
"Starting isolate mixin for ${this.runtimeType} took ${DateTime.now().millisecondsSinceEpoch - _time} ms");
});
} on TimeoutException {
throw TimeoutException(
"Timeout while starting isolate $isolateInitParams");
}
}