Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

删除已注释掉的代码以及补齐@Override注解 #2763

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@ public Job resume(boolean foreground) {

runInBackground.set(!foreground);

// if (foreground) {
// if (foregroundUpdatedHandler != null) {
// foregroundUpdatedHandler.handle(this);
// }
// }
if (statusUpdateHandler != null) {
statusUpdateHandler.handle(process.status());
}
Expand All @@ -114,14 +109,11 @@ public Job suspend() {
} catch (IllegalStateException ignore) {
return this;
}
// if (!runInBackground.get() && foregroundUpdatedHandler != null) {
// foregroundUpdatedHandler.handle(null);
// }

if (statusUpdateHandler != null) {
statusUpdateHandler.handle(process.status());
}

// shell.setForegroundJob(null);
jobHandler.onSuspend(this);
return this;
}
Expand All @@ -142,10 +134,12 @@ public Process process() {
return process;
}

@Override
public ExecStatus status() {
return process.status();
}

@Override
public String line() {
return line;
}
Expand All @@ -168,24 +162,18 @@ public Job toBackground() {
}
}

// shell.setForegroundJob(null);
// jobHandler.onBackground(this);
return this;
}

@Override
public Job toForeground() {
if (this.runInBackground.get()) {
if (runInBackground.compareAndSet(true, false)) {
// if (foregroundUpdatedHandler != null) {
// foregroundUpdatedHandler.handle(this);
// }
process.toForeground();
if (statusUpdateHandler != null) {
statusUpdateHandler.handle(process.status());
}

// shell.setForegroundJob(this);
jobHandler.onForeground(this);
}
}
Expand All @@ -205,9 +193,6 @@ public Job run() {

@Override
public Job run(boolean foreground) {
// if (foreground && foregroundUpdatedHandler != null) {
// foregroundUpdatedHandler.handle(this);
// }

actualStatus = ExecStatus.RUNNING;
if (statusUpdateHandler != null) {
Expand All @@ -218,15 +203,6 @@ public Job run(boolean foreground) {
process.setSession(this.session);
process.run(foreground);

// if (!foreground && foregroundUpdatedHandler != null) {
// foregroundUpdatedHandler.handle(null);
// }
//
// if (foreground) {
// shell.setForegroundJob(this);
// } else {
// shell.setForegroundJob(null);
// }
if (this.status() == ExecStatus.RUNNING) {
if (foreground) {
jobHandler.onForeground(this);
Expand All @@ -247,25 +223,12 @@ public TerminatedHandler(JobControllerImpl controller) {

@Override
public void handle(Integer exitCode) {
// if (!runInBackground.get() && actualStatus.equals(ExecStatus.RUNNING)) {
// 只有前台在运行的任务,才需要调用foregroundUpdateHandler
// if (foregroundUpdatedHandler != null) {
// foregroundUpdatedHandler.handle(null);
// }
// }
jobHandler.onTerminated(JobImpl.this);
controller.removeJob(JobImpl.this.id);
if (statusUpdateHandler != null) {
statusUpdateHandler.handle(ExecStatus.TERMINATED);
}
terminateFuture.complete();

// save command history (move to JobControllerImpl.ShellJobHandler.onTerminated)
// Term term = shell.term();
// if (term instanceof TermImpl) {
// List<int[]> history = ((TermImpl) term).getReadline().getHistory();
// FileUtils.saveCommandHistory(history, new File(Constants.CMD_HISTORY_FILE));
// }
}
}

Expand Down