Bugfixes in sync primitives

This commit is contained in:
konsoletyper 2015-02-24 21:08:56 +03:00
parent 0c5fb8d9b0
commit 7d62c16c8d
3 changed files with 8 additions and 5 deletions

View File

@ -216,6 +216,9 @@ public class TObject {
@Rename("wait") @Rename("wait")
public final void wait0(long timeout, int nanos, final AsyncCallback<Void> callback) { public final void wait0(long timeout, int nanos, final AsyncCallback<Void> callback) {
if (!holdsLock(this)) {
throw new TIllegalMonitorStateException();
}
final NotifyListenerImpl listener = new NotifyListenerImpl(this, callback, monitor.count); final NotifyListenerImpl listener = new NotifyListenerImpl(this, callback, monitor.count);
monitor.notifyListeners.add(listener); monitor.notifyListeners.add(listener);
if (timeout > 0 || nanos > 0) { if (timeout > 0 || nanos > 0) {

View File

@ -76,7 +76,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
try { try {
MethodReference monitorEnterRef = new MethodReference( MethodReference monitorEnterRef = new MethodReference(
Object.class, "monitorEnter", Object.class, void.class); Object.class, "monitorEnter", Object.class, void.class);
writer.appendMethodBody(monitorEnterRef).append("("); writer.append("return ").appendMethodBody(monitorEnterRef).append("(");
statement.getObjectRef().acceptVisitor(this); statement.getObjectRef().acceptVisitor(this);
writer.append(",").ws(); writer.append(",").ws();
writer.append("$rt_continue($part_").append(statement.getAsyncTarget()).append(')'); writer.append("$rt_continue($part_").append(statement.getAsyncTarget()).append(')');

View File

@ -39,12 +39,12 @@ public class AsyncMethodGenerator implements Generator, DependencyPlugin {
public void generate(GeneratorContext context, SourceWriter writer, MethodReference methodRef) throws IOException { public void generate(GeneratorContext context, SourceWriter writer, MethodReference methodRef) throws IOException {
MethodReference asyncRef = getAsyncReference(methodRef); MethodReference asyncRef = getAsyncReference(methodRef);
writer.append("var callback").ws().append("=").ws().append("function()").ws().append("{};").softNewLine(); writer.append("var callback").ws().append("=").ws().append("function()").ws().append("{};").softNewLine();
writer.append("callback.").appendMethod(completeMethod).ws().append("=").ws().append("function($this,").ws() writer.append("callback.").appendMethod(completeMethod).ws().append("=").ws().append("function(val)").ws()
.append("val)").ws().append("{").indent().softNewLine(); .append("{").indent().softNewLine();
writer.append("return $return($rt_asyncResult(val));").softNewLine(); writer.append("return $return($rt_asyncResult(val));").softNewLine();
writer.outdent().append("};").softNewLine(); writer.outdent().append("};").softNewLine();
writer.append("callback.").appendMethod(errorMethod).ws().append("=").ws().append("function($this,").ws() writer.append("callback.").appendMethod(errorMethod).ws().append("=").ws().append("function(e)").ws()
.append("e)").ws().append("{").indent().softNewLine(); .append("{").indent().softNewLine();
writer.append("return $return($rt_asyncError(e));").softNewLine(); writer.append("return $return($rt_asyncError(e));").softNewLine();
writer.outdent().append("};").softNewLine(); writer.outdent().append("};").softNewLine();
writer.append("try").ws().append("{").indent().softNewLine(); writer.append("try").ws().append("{").indent().softNewLine();