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")
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);
monitor.notifyListeners.add(listener);
if (timeout > 0 || nanos > 0) {

View File

@ -76,7 +76,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
try {
MethodReference monitorEnterRef = new MethodReference(
Object.class, "monitorEnter", Object.class, void.class);
writer.appendMethodBody(monitorEnterRef).append("(");
writer.append("return ").appendMethodBody(monitorEnterRef).append("(");
statement.getObjectRef().acceptVisitor(this);
writer.append(",").ws();
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 {
MethodReference asyncRef = getAsyncReference(methodRef);
writer.append("var callback").ws().append("=").ws().append("function()").ws().append("{};").softNewLine();
writer.append("callback.").appendMethod(completeMethod).ws().append("=").ws().append("function($this,").ws()
.append("val)").ws().append("{").indent().softNewLine();
writer.append("callback.").appendMethod(completeMethod).ws().append("=").ws().append("function(val)").ws()
.append("{").indent().softNewLine();
writer.append("return $return($rt_asyncResult(val));").softNewLine();
writer.outdent().append("};").softNewLine();
writer.append("callback.").appendMethod(errorMethod).ws().append("=").ws().append("function($this,").ws()
.append("e)").ws().append("{").indent().softNewLine();
writer.append("callback.").appendMethod(errorMethod).ws().append("=").ws().append("function(e)").ws()
.append("{").indent().softNewLine();
writer.append("return $return($rt_asyncError(e));").softNewLine();
writer.outdent().append("};").softNewLine();
writer.append("try").ws().append("{").indent().softNewLine();