Fix code styling

This commit is contained in:
konsoletyper 2015-02-10 22:10:06 +04:00
parent b69b5b9219
commit 857ed9754e
2 changed files with 24 additions and 42 deletions

View File

@ -17,32 +17,27 @@ package org.teavm.classlib.java.lang;
import org.teavm.dom.browser.Window;
import org.teavm.javascript.spi.Async;
import org.teavm.javascript.spi.Rename;
import org.teavm.javascript.spi.Superclass;
import org.teavm.jso.JS;
import org.teavm.jso.JSArray;
import org.teavm.jso.JSFunctor;
import org.teavm.jso.JSObject;
import org.teavm.platform.Platform;
import org.teavm.platform.async.AsyncCallback;
/**
*
* @author Alexey Andreev <konsoletyper@gmail.com>
*/
@Superclass("")
public class TObject {
private static final Window window = (Window)JS.getGlobal();
private TThread owner;
private TObject monitorLock;
private int monitorCount=0;
private int monitorCount;
private JSArray<NotifyListener> notifyListeners;
private final Window window = (Window)JS.getGlobal();
@JSFunctor
private static interface NotifyListener extends JSObject{
interface NotifyListener extends JSObject {
void handleNotify();
}
@ -59,11 +54,9 @@ public class TObject {
}
o.owner = TThread.currentThread();
o.monitorCount++;
}
static void monitorExit(TObject o){
o.monitorCount--;
if (o.monitorCount == 0 && o.monitorLock != null) {
o.owner = null;
@ -138,10 +131,8 @@ public class TObject {
listeners.shift().handleNotify();
}
}
}
@Rename("wait")
public final void wait0(long timeout) throws TInterruptedException{
try {
@ -155,7 +146,6 @@ public class TObject {
@Rename("wait")
public native final void wait0(long timeout, int nanos) throws TInterruptedException;
@Rename("wait")
public final void wait0(long timeout, int nanos, final AsyncCallback<Void> callback) {
if (notifyListeners == null) {
@ -163,7 +153,6 @@ public class TObject {
}
final TThread currentThread = TThread.currentThread();
notifyListeners.push(new NotifyListener() {
@Override
public void handleNotify() {
TThread.setCurrentThread(currentThread);
@ -172,9 +161,7 @@ public class TObject {
} finally {
TThread.setCurrentThread(TThread.getMainThread());
}
}
});
}

View File

@ -27,7 +27,6 @@ import org.teavm.platform.async.AsyncCallback;
* @author Alexey Andreev
*/
public class TThread extends TObject implements TRunnable {
private static Window window = (Window)JS.getGlobal();
private static TThread mainThread = new TThread(TString.wrap("main"));
private static TThread currentThread = mainThread;
@ -73,8 +72,6 @@ public class TThread extends TObject implements TRunnable {
activeCount--;
setCurrentThread(mainThread);
}
}
static void setCurrentThread(TThread thread){
@ -136,13 +133,11 @@ public class TThread extends TObject implements TRunnable {
return TObject.holdsLock(obj);
}
@Async
public static native void sleep(long millis) throws TInterruptedException;
private static void sleep(long millis, final AsyncCallback<Void> callback) {
final TThread current = currentThread();
window.setTimeout(new TimerHandler() {
@Override public void onTimer() {
setCurrentThread(current);