mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Merge pull request #185 from shannah/master
Fixed NPE in LinkedList.remove(e)
This commit is contained in:
commit
1bb36b98b2
|
@ -343,10 +343,10 @@ public class TLinkedList<E> extends TAbstractSequentialList<E> implements TDeque
|
|||
}
|
||||
removeEntry(currentEntry);
|
||||
if (currentEntry == prevEntry) {
|
||||
prevEntry = nextEntry.previous;
|
||||
prevEntry = hasNext() ? nextEntry.previous : null;
|
||||
--index;
|
||||
} else if (currentEntry == nextEntry) {
|
||||
nextEntry = prevEntry.next;
|
||||
nextEntry = hasPrevious() ? prevEntry.next : null;
|
||||
}
|
||||
--size;
|
||||
version = modCount;
|
||||
|
|
|
@ -81,4 +81,33 @@ public class TTimer extends TObject {
|
|||
};
|
||||
task.nativeTimerId = Window.setTimeout(handler, (int) delay);
|
||||
}
|
||||
|
||||
public void scheduleAtFixedRate(final TTimerTask task, long delay, long period) {
|
||||
if (cancelled || task.timer != null || task.nativeTimerId >= 0) {
|
||||
throw new TIllegalStateException();
|
||||
}
|
||||
final long[] nextStartTime = new long[]{System.currentTimeMillis() + delay};
|
||||
task.timer = this;
|
||||
TimerHandler handler = new TimerHandler() {
|
||||
@Override public void onTimer() {
|
||||
new Thread(() -> {
|
||||
if (cancelled || task.timer == null) {
|
||||
return;
|
||||
}
|
||||
long nextDelay = nextStartTime[0] - System.currentTimeMillis();
|
||||
if (nextDelay < 0 ) {
|
||||
nextDelay = 0;
|
||||
}
|
||||
task.nativeTimerId = Window.setTimeout(this, (int) nextDelay);
|
||||
nextStartTime[0] += period;
|
||||
TTimerTask.performOnce(task);
|
||||
if (!cancelled) {
|
||||
task.timer = TTimer.this;
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
};
|
||||
task.nativeTimerId = Window.setTimeout(handler, (int) delay);
|
||||
nextStartTime[0] += period;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user