Skip to content
Merged
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 @@ -27,22 +27,27 @@
*/
public class ConsoleLineTracker implements IConsoleLineTrackerExtension {

private enum State {
UNINITIALIZED, INITIALIZED, CLOSED, DISPOSED,
}

private static final Object LOCK = new Object();
private static IConsole console;
private static List<IRegion> lines = new ArrayList<>();

private static boolean consoleClosed = true;
private static State state = State.UNINITIALIZED;

@Override
public void dispose() {
// do nothing
state = State.DISPOSED;
}

@Override
public void init(IConsole c) {
synchronized (lines) {
synchronized (LOCK) {
ConsoleLineTracker.console = c;
lines = new ArrayList<>();
consoleClosed = false;
state = State.INITIALIZED;
}
}

Expand Down Expand Up @@ -86,12 +91,12 @@ public static IDocument getDocument() {
}

public static void waitForConsole() {
synchronized (lines) {
if (consoleClosed) {
synchronized (LOCK) {
if (state == State.CLOSED) {
return;
}
try {
lines.wait(20000);
LOCK.wait(20000);
}
catch (InterruptedException ie) {
// do nothing
Expand All @@ -101,15 +106,15 @@ public static void waitForConsole() {

@Override
public void consoleClosed() {
synchronized (lines) {
consoleClosed = true;
synchronized (LOCK) {
state = State.CLOSED;
lines.notifyAll();
}
}

public static boolean isClosed() {
synchronized (lines) {
return consoleClosed;
synchronized (LOCK) {
return state == State.CLOSED;
}
}
}
Loading