use of com.sk89q.skmcl.concurrent.WorkUnit in project SKMCLauncher by SKCraft.
the class HttpDownloader method call.
@Override
public List<Future<RemoteFile>> call() throws ExecutionException, InterruptedException {
executor.shutdown();
TimerTask timerTask = SwingProgressObserver.updatePeriodically(this);
try {
try {
while (!executor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS)) ;
} catch (InterruptedException e) {
executor.shutdownNow();
throw new InterruptedException();
}
WorkUnit parts = split(1, executed.size());
// Run through all the jobs to see whether any failed
synchronized (executed) {
for (Future<RemoteFile> future : executed) {
RemoteFile file = future.get();
}
}
return executed;
} finally {
timerTask.cancel();
}
}
use of com.sk89q.skmcl.concurrent.WorkUnit in project SKMCLauncher by SKCraft.
the class LaunchWorker method call.
@Override
public LaunchedProcess call() throws LauncherException, InterruptedException {
WorkUnit step1 = split(0.1), step2 = split(0.8), step3 = split(0.1);
// First resolve the version (i.e. latest -> which version is "latest"?)
setLocalizedTitle(_("launch.launchingTitle", profile.toString()));
step1.push(0, _("launch.checkingVersion"));
Instance instance = getInstance();
Persistence.commitAndForget(profile);
// Then attempt to launch
// But an update MAY be required
step2.push(0, _("launch.launching"));
try {
return launch(instance);
} catch (UpdateRequiredException e) {
// Update required, so we're going to go to the update step
} catch (IOException e) {
throw new LauncherException(e, _("launch.launchFailed"));
}
if (!offline) {
setLocalizedTitle(_("launch.updatingTitle", profile.toString()));
step2.push(0, _("launch.updating"));
update(instance, step2);
} else {
throw new LauncherException("Can't update if offline", _("launch.onlineModeRequired"));
}
// Update's done, so let's try launching one more time
setLocalizedTitle(_("launch.launchingTitle", profile.toString()));
step3.push(0, _("launch.launching"));
try {
return launch(instance);
} catch (UpdateRequiredException e) {
// but perhaps something failed
throw new LauncherException(e, _("updater.launchFailed"));
} catch (IOException e) {
throw new LauncherException(e, _("updater.launchFailed"));
}
}
use of com.sk89q.skmcl.concurrent.WorkUnit in project SKMCLauncher by SKCraft.
the class MinecraftUpdater method call.
@Override
public MinecraftInstall call() throws Exception {
try {
WorkUnit step1 = split(0.02), step2 = split(0.02), step3 = split(0.96);
if (!hasSystemProperty(MinecraftUpdater.class, "skipAssets")) {
installAssets(step1);
checkInterrupted();
}
installGame(step2);
checkInterrupted();
logger.log(Level.INFO, "Install tasks enumerated; now installing...");
installer.addObserver(step3);
installer.call();
return instance;
} finally {
executor.shutdownNow();
}
}
use of com.sk89q.skmcl.concurrent.WorkUnit in project SKMCLauncher by SKCraft.
the class InstallerRuntime method call.
@Override
public InstallerRuntime call() throws Exception {
WorkUnit step1 = split(0.9), step2 = split(0.1, tasks.size());
step1.push(0, _("installer.preparingDownload", tasks.size()));
httpDownloader.addObserver(step1);
httpDownloader.call();
for (Runnable task : tasks) {
checkInterrupted();
step2.push(0, _("installer.installing", task.toString()));
logger.log(Level.INFO, "Executing {0}...", task.toString());
task.run();
step2.advance();
}
return this;
}
Aggregations