notifyIsolate method
Notifies the isolate associated with taskId
to update its status to message
.
If the isolate is not found and the message is to start downloading, resumes the task.
Implementation
void notifyIsolate(String taskId, DownloadStatus message) {
DownloadIsolateInstance? isolate = findIsolateByTaskId(taskId);
logV('[DownloadIsolatePool] notifyIsolate: ${isolate.toString()} $message');
if (isolate == null && message == DownloadStatus.DOWNLOADING) {
final task = findTaskById(taskId);
if (task == null) return;
resumeTask(task);
} else {
isolate?.task?.status = message;
isolate?.controlPort?.send(DownloadIsolateMsg(
IsolateMsgType.task,
isolate.task,
));
}
}